mina

package
v0.16.1 Latest Latest
Warning

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

Go to latest
Published: Mar 10, 2024 License: GPL-3.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Cube    = iota // x^3
	Quint          // x^5
	Sept           // x^7
	Inverse        // x^-1
)
View Source
const (
	ThreeW = iota
	FiveW
	Three
)
View Source
const (
	TestNet = iota
	MainNet
	NullNet
)

Variables

This section is empty.

Functions

func NewKeys

func NewKeys() (*PublicKey, *SecretKey, error)

NewKeys creates a new keypair using a CSPRNG

func NewKeysFromReader

func NewKeysFromReader(reader io.Reader) (*PublicKey, *SecretKey, error)

NewKeysFromReader creates a new keypair using the specified reader

Types

type BitVector

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

A BitVector is a variable sized vector of bits. It supports lookups, sets, appends, insertions, and deletions.

This class is not thread safe.

func NewBitVector

func NewBitVector(data []byte, length int) *BitVector

NewBitVector creates and initializes a new bit vector with length elements, using data as its initial contents.

func (*BitVector) Append

func (vector *BitVector) Append(bit byte)

Append adds a bit to the end of a bit vector.

func (*BitVector) Bytes

func (vector *BitVector) Bytes() []byte

Bytes returns a slice of the contents of the bit vector. If the caller changes the returned slice, the contents of the bit vector may change.

func (*BitVector) Delete

func (vector *BitVector) Delete(index int)

Delete removes the bit in the supplied index of the bit vector. All bits in positions greater than or equal to index before the call will be shifted down by one.

func (*BitVector) Element

func (vector *BitVector) Element(i int) byte

Element returns the bit in the ith index of the bit vector. Returned value is either 1 or 0.

func (*BitVector) Insert

func (vector *BitVector) Insert(bit byte, index int)

Insert inserts bit into the supplied index of the bit vector. All bits in positions greater than or equal to index before the call will be shifted up by one.

func (*BitVector) Length

func (vector *BitVector) Length() int

Length returns the current number of elements in the bit vector.

func (*BitVector) Set

func (vector *BitVector) Set(bit byte, index int)

Set changes the bit in the ith index of the bit vector to the value specified in bit.

type Context

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

func (*Context) Digest

func (ctx *Context) Digest() *fq.Fq

func (*Context) Init

func (ctx *Context) Init(pType Permutation, networkId NetworkType) *Context

func (*Context) Update

func (ctx *Context) Update(fields []*fp.Fp)

type MinaTSchnorrHandler

type MinaTSchnorrHandler struct{}

func (MinaTSchnorrHandler) DeriveChallenge

func (m MinaTSchnorrHandler) DeriveChallenge(msg []byte, pubKey curves.Point, r curves.Point) (curves.Scalar, error)

type NetworkType

type NetworkType int

NetworkType is which Mina network id to use

type Permutation

type Permutation int

Permutation is the permute function to use

func (Permutation) Permute

func (p Permutation) Permute(ctx *Context)

Permute executes the poseidon hash function

type PublicKey

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

PublicKey is the verification key

func (PublicKey) GenerateAddress

func (pk PublicKey) GenerateAddress() string

GenerateAddress converts the public key to an address

func (PublicKey) MarshalBinary

func (pk PublicKey) MarshalBinary() ([]byte, error)

func (*PublicKey) ParseAddress

func (pk *PublicKey) ParseAddress(b58 string) error

ParseAddress converts a given string into a public key returning an error on failure

func (*PublicKey) SetPointPallas

func (pk *PublicKey) SetPointPallas(pallas *curves.PointPallas)

func (*PublicKey) UnmarshalBinary

func (pk *PublicKey) UnmarshalBinary(input []byte) error

func (*PublicKey) VerifyMessage

func (pk *PublicKey) VerifyMessage(sig *Signature, message string) error

VerifyMessage checks if the claimed signature on a _string_ is valid. this is nonstandard; see above.

func (*PublicKey) VerifyTransaction

func (pk *PublicKey) VerifyTransaction(sig *Signature, transaction *Transaction) error

VerifyTransaction checks if the signature is over the given transaction using this public key

type SBox

type SBox int

SBox is the type of exponentiation to perform

func (SBox) Exp

func (sbox SBox) Exp(f *fp.Fp)

Exp mutates f by computing x^3, x^5, x^7 or x^-1 as described in https://eprint.iacr.org/2019/458.pdf page 8

type SecretKey

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

SecretKey is the signing key

func (SecretKey) GetPublicKey

func (sk SecretKey) GetPublicKey() *PublicKey

GetPublicKey returns the corresponding verification

func (SecretKey) MarshalBinary

func (sk SecretKey) MarshalBinary() ([]byte, error)

func (*SecretKey) SetFq

func (sk *SecretKey) SetFq(fq *fq.Fq)

func (*SecretKey) SignMessage

func (sk *SecretKey) SignMessage(message string) (*Signature, error)

SignMessage signs a _string_. this is somewhat non-standard; we do it by just adding bytes to the roinput. See https://github.com/MinaProtocol/c-reference-signer/blob/master/crypto.c#L1020

func (*SecretKey) SignTransaction

func (sk *SecretKey) SignTransaction(transaction *Transaction) (*Signature, error)

SignTransaction generates a signature over the specified txn and network id See https://github.com/MinaProtocol/c-reference-signer/blob/master/crypto.c#L1020

func (*SecretKey) UnmarshalBinary

func (sk *SecretKey) UnmarshalBinary(input []byte) error

type Signature

type Signature struct {
	R *fp.Fp
	S *fq.Fq
}

Signature is a Mina compatible signature either for payment or delegation

func (Signature) MarshalBinary

func (sig Signature) MarshalBinary() ([]byte, error)

func (*Signature) UnmarshalBinary

func (sig *Signature) UnmarshalBinary(input []byte) error

type Transaction

type Transaction struct {
	Fee, FeeToken        uint64
	FeePayerPk           *PublicKey
	Nonce, ValidUntil    uint32
	Memo                 string
	Tag                  [3]bool
	SourcePk, ReceiverPk *PublicKey
	TokenId, Amount      uint64
	Locked               bool
	NetworkId            NetworkType
}

Transaction is a Mina transaction for payments or delegations

func (*Transaction) MarshalBinary

func (txn *Transaction) MarshalBinary() ([]byte, error)

func (*Transaction) UnmarshalBinary

func (txn *Transaction) UnmarshalBinary(input []byte) error

func (*Transaction) UnmarshalJSON

func (txn *Transaction) UnmarshalJSON(input []byte) error

Jump to

Keyboard shortcuts

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