fiat

package
v0.26.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 6, 2024 License: MIT Imports: 3 Imported by: 0

README

The code in this package was autogenerated by the fiat-crypto project
at version v0.0.9 from a formally verified model, and by the addchain
project at a recent tip version.

    docker build -t fiat-crypto:v0.0.9 .
    go install github.com/mmcloughlin/addchain/cmd/addchain@v0.3.1-0.20211027081849-6a7d3decbe08
    go run generate.go

fiat-crypto code comes under the following license.

    Copyright (c) 2015-2020 The fiat-crypto Authors. All rights reserved.

    Redistribution and use in source and binary forms, with or without
    modification, are permitted provided that the following conditions are
    met:

        1. Redistributions of source code must retain the above copyright
        notice, this list of conditions and the following disclaimer.

    THIS SOFTWARE IS PROVIDED BY the fiat-crypto authors "AS IS"
    AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
    THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
    PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL Berkeley Software Design,
    Inc. BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
    EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
    PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
    PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
    LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
    NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
    SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

The authors are listed at

    https://github.com/mit-plv/fiat-crypto/blob/master/AUTHORS

Documentation

Overview

Copyright 2021 The Go Authors. All rights reserved. Use of this source code is governed by a BSD-style license that can be found in the LICENSE file. Code generated by addchain. DO NOT EDIT.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type SM2P256Element

type SM2P256Element struct {
	// contains filtered or unexported fields
}

SM2P256Element is an integer modulo 2^256 - 2^224 - 2^96 + 2^64 - 1.

The zero value is a valid zero element.

func (*SM2P256Element) Add

func (e *SM2P256Element) Add(t1, t2 *SM2P256Element) *SM2P256Element

Add sets e = t1 + t2, and returns e.

func (*SM2P256Element) Bytes

func (e *SM2P256Element) Bytes() []byte

Bytes returns the 32-byte big-endian encoding of e.

func (*SM2P256Element) Equal

func (e *SM2P256Element) Equal(t *SM2P256Element) int

Equal returns 1 if e == t, and zero otherwise.

func (*SM2P256Element) Invert

Invert sets e = 1/x, and returns e.

If x == 0, Invert returns e = 0.

func (*SM2P256Element) IsZero

func (e *SM2P256Element) IsZero() int

IsZero returns 1 if e == 0, and zero otherwise.

func (*SM2P256Element) Mul

func (e *SM2P256Element) Mul(t1, t2 *SM2P256Element) *SM2P256Element

Mul sets e = t1 * t2, and returns e.

func (*SM2P256Element) One

func (e *SM2P256Element) One() *SM2P256Element

One sets e = 1, and returns e.

func (*SM2P256Element) Select

func (v *SM2P256Element) Select(a, b *SM2P256Element, cond int) *SM2P256Element

Select sets v to a if cond == 1, and to b if cond == 0.

func (*SM2P256Element) Set

Set sets e = t, and returns e.

func (*SM2P256Element) SetBytes

func (e *SM2P256Element) SetBytes(v []byte) (*SM2P256Element, error)

SetBytes sets e = v, where v is a big-endian 32-byte encoding, and returns e. If v is not 32 bytes or it encodes a value higher than 2^256 - 2^224 - 2^96 + 2^64 - 1, SetBytes returns nil and an error, and e is unchanged.

func (*SM2P256Element) Square

Square sets e = t * t, and returns e.

func (*SM2P256Element) Sub

func (e *SM2P256Element) Sub(t1, t2 *SM2P256Element) *SM2P256Element

Sub sets e = t1 - t2, and returns e.

type SM2P256OrderElement added in v0.14.1

type SM2P256OrderElement struct {
	// contains filtered or unexported fields
}

SM2P256OrderElement is an integer modulo 0xFFFFFFFEFFFFFFFFFFFFFFFFFFFFFFFF7203DF6B21C6052B53BBF40939D54123.

The zero value is a valid zero element.

func (*SM2P256OrderElement) Add added in v0.14.1

Add sets e = t1 + t2, and returns e.

func (*SM2P256OrderElement) Bytes added in v0.14.1

func (e *SM2P256OrderElement) Bytes() []byte

Bytes returns the 32-byte big-endian encoding of e.

func (*SM2P256OrderElement) Mul added in v0.14.1

Mul sets e = t1 * t2, and returns e.

func (*SM2P256OrderElement) One added in v0.14.1

One sets e = 1, and returns e.

func (*SM2P256OrderElement) Select added in v0.14.1

Select sets v to a if cond == 1, and to b if cond == 0.

func (*SM2P256OrderElement) SetBytes added in v0.14.1

func (e *SM2P256OrderElement) SetBytes(v []byte) (*SM2P256OrderElement, error)

SetBytes sets e = v, where v is a big-endian 32-byte encoding, and returns e. If v is not 32 bytes or it encodes a value higher than 2^256 - 2^224 - 2^96 + 2^64 - 1, SetBytes returns nil and an error, and e is unchanged.

func (*SM2P256OrderElement) Square added in v0.14.1

Square sets e = t * t, and returns e.

func (*SM2P256OrderElement) Sub added in v0.14.1

Sub sets e = t1 - t2, and returns e.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL