crypto

package
v0.0.0-...-f36aa9e Latest Latest
Warning

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

Go to latest
Published: Jul 1, 2022 License: MIT Imports: 10 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AppendMultisigToLogicSig

func AppendMultisigToLogicSig(lsig *types.LogicSig, sk ed25519.PrivateKey) error

AppendMultisigToLogicSig adds a new signature to multisigned LogicSig

func AppendMultisigTransaction

func AppendMultisigTransaction(sk ed25519.PrivateKey, ma MultisigAccount, preStxBytes []byte) (txid string, stxBytes []byte, err error)

AppendMultisigTransaction appends the signature corresponding to the given private key, returning an encoded signed multisig transaction including the signature. While we could compute the multisig preimage from the multisig blob, we ask the caller to pass it back in, to explicitly check that they know who they are signing as.

func ComputeGroupID

func ComputeGroupID(txgroup []types.Transaction) (gid types.Digest, err error)

ComputeGroupID returns group ID for a group of transactions

func LogicSigAddress

func LogicSigAddress(lsig types.LogicSig) types.Address

LogicSigAddress returns contract (escrow) address

func MakeLogicSig

func MakeLogicSig(program []byte, args [][]byte, sk ed25519.PrivateKey, ma MultisigAccount) (lsig types.LogicSig, err error)

MakeLogicSig produces a new LogicSig signature. The function can work in three modes: 1. If no sk and ma provided then it returns contract-only LogicSig 2. If no ma provides, it returns Sig delegated LogicSig 3. If both sk and ma specified the function returns Multisig delegated LogicSig

func MergeMultisigTransactions

func MergeMultisigTransactions(stxsBytes ...[]byte) (txid string, stxBytes []byte, err error)

MergeMultisigTransactions merges the given (partially) signed multisig transactions, and returns an encoded signed multisig transaction with the component signatures.

func RandomBytes

func RandomBytes(s []byte)

RandomBytes fills the passed slice with randomness, and panics if it is unable to do so

func SignBid

func SignBid(sk ed25519.PrivateKey, bid types.Bid) (signedBid []byte, err error)

SignBid accepts a private key and a bid, and returns the signature of the bid under that key

func SignBytes

func SignBytes(sk ed25519.PrivateKey, bytesToSign []byte) (signature []byte, err error)

SignBytes signs the bytes and returns the signature

func SignLogicsigTransaction

func SignLogicsigTransaction(lsig types.LogicSig, tx types.Transaction) (txid string, stxBytes []byte, err error)

SignLogicsigTransaction takes LogicSig object and a transaction and returns the bytes of a signed transaction ready to be broadcasted to the network Note, LogicSig actually can be attached to any transaction (with matching sender field for Sig and Multisig cases) and it is a program's responsibility to approve/decline the transaction

func SignMultisigTransaction

func SignMultisigTransaction(sk ed25519.PrivateKey, ma MultisigAccount, tx types.Transaction) (txid string, stxBytes []byte, err error)

SignMultisigTransaction signs the given transaction, and multisig preimage, with the private key, returning the bytes of a signed transaction with the multisig field partially populated, ready to be passed to other multisig signers to sign or broadcast.

func SignTransaction

func SignTransaction(sk ed25519.PrivateKey, tx types.Transaction) (txid string, stxBytes []byte, err error)

SignTransaction accepts a private key and a transaction, and returns the bytes of a signed transaction ready to be broadcasted to the network

func VerifyBytes

func VerifyBytes(pk ed25519.PublicKey, message, signature []byte) bool

VerifyBytes verifies that the signature is valid

func VerifyLogicSig

func VerifyLogicSig(lsig types.LogicSig, sender types.Address) (result bool)

VerifyLogicSig verifies LogicSig against assumed sender address

func VerifyMultisig

func VerifyMultisig(addr types.Address, message []byte, msig types.MultisigSig) bool

VerifyMultisig verifies an assembled MultisigSig

Types

type Account

type Account struct {
	PublicKey  ed25519.PublicKey
	PrivateKey ed25519.PrivateKey
	Address    types.Address
}

Account holds both the public and private information associated with an Algorand address

func GenerateAccount

func GenerateAccount() (kp Account)

GenerateAccount generates a random Account

type MultisigAccount

type MultisigAccount struct {
	// Version is the version of this multisig
	Version uint8
	// Threshold is how many signatures are needed to fully sign as this address
	Threshold uint8
	// Pks is an ordered list of public keys that could potentially sign a message
	Pks []ed25519.PublicKey
}

MultisigAccount is a convenience type for holding multisig preimage data

func MultisigAccountFromSig

func MultisigAccountFromSig(sig types.MultisigSig) (ma MultisigAccount, err error)

MultisigAccountFromSig is a convenience method that creates an account from a sig in a signed tx. Useful for getting addresses from signed msig txs, etc.

func MultisigAccountWithParams

func MultisigAccountWithParams(version uint8, threshold uint8, addrs []types.Address) (ma MultisigAccount, err error)

MultisigAccountWithParams creates a MultisigAccount with the given parameters

func (MultisigAccount) Address

func (ma MultisigAccount) Address() (addr types.Address, err error)

Address takes this multisig preimage data, and generates the corresponding identifying address, committing to the exact group, version, and public keys that it requires to sign. Hash("MultisigAddr" || version uint8 || threshold uint8 || PK1 || PK2 || ...)

func (MultisigAccount) Blank

func (ma MultisigAccount) Blank() bool

Blank return true if MultisigAccount is empty struct containing []ed25519.PublicKey cannot be compared

func (MultisigAccount) Validate

func (ma MultisigAccount) Validate() (err error)

Validate ensures that this multisig setup is a valid multisig account

Jump to

Keyboard shortcuts

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