Documentation ¶
Index ¶
- Constants
- func HashRep(h Hashable) []byte
- func NewHash() hash.Hash
- func VrfKeygen() (pub VrfPubkey, priv VrfPrivkey)
- func VrfKeygenFromSeed(seed [32]byte) (pub VrfPubkey, priv VrfPrivkey)
- type Digest
- type HashID
- type Hashable
- type VRFProof
- type VRFSecrets
- type VRFVerifier
- type VrfOutput
- type VrfPrivkey
- type VrfProof
- type VrfPubkey
Constants ¶
const DigestSize = sha512.Size256
DigestSize is the number of bytes in the preferred hash Digest used here.
Variables ¶
This section is empty.
Functions ¶
func VrfKeygen ¶
func VrfKeygen() (pub VrfPubkey, priv VrfPrivkey)
VrfKeygen generates a random VRF keypair.
func VrfKeygenFromSeed ¶
func VrfKeygenFromSeed(seed [32]byte) (pub VrfPubkey, priv VrfPrivkey)
VrfKeygenFromSeed deterministically generates a VRF keypair from 32 bytes of (secret) entropy.
Types ¶
type Digest ¶
type Digest [DigestSize]byte
Digest represents a 32-byte value holding the 256-bit Hash digest.
func DigestFromString ¶
DigestFromString converts a string to a Digest
func (Digest) TrimUint64 ¶
TrimUint64 returns the top 64 bits of the digest and converts to uint64
type HashID ¶
type HashID string
HashID is a domain separation prefix for an object type that might be hashed This ensures, for example, the hash of a transaction will never collide with the hash of a vote
const ( AppIndex HashID = "appID" // ARCReserved is used to reserve prefixes starting with `arc` to // ARCs-related hashes https://github.com/algorandfoundation/ARCs // The prefix for ARC-XXXX should start with: // "arcXXXX" (where "XXXX" is the 0-padded number of the ARC) // For example ARC-0003 can use any prefix starting with "arc0003" ARCReserved HashID = "arc" AuctionBid HashID = "aB" AuctionDeposit HashID = "aD" AuctionOutcomes HashID = "aO" AuctionParams HashID = "aP" AuctionSettlement HashID = "aS" AgreementSelector HashID = "AS" BlockHeader256 HashID = "B256" BlockHeader HashID = "BH" BalanceRecord HashID = "BR" Credential HashID = "CR" Genesis HashID = "GE" KeysInMSS HashID = "KP" MerkleArrayNode HashID = "MA" MerkleVectorCommitmentBottomLeaf HashID = "MB" Message HashID = "MX" NetPrioResponse HashID = "NPR" OneTimeSigKey1 HashID = "OT1" OneTimeSigKey2 HashID = "OT2" PaysetFlat HashID = "PF" Payload HashID = "PL" Program HashID = "Program" ProgramData HashID = "ProgData" ProposerSeed HashID = "PS" ParticipationKeys HashID = "PK" Seed HashID = "SD" SpecialAddr HashID = "SpecialAddr" SignedTxnInBlock HashID = "STIB" StateProofCoin HashID = "spc" StateProofMessage HashID = "spm" StateProofPart HashID = "spp" StateProofSig HashID = "sps" TestHashable HashID = "TE" TxGroup HashID = "TG" TxnMerkleLeaf HashID = "TL" Transaction HashID = "TX" Vote HashID = "VO" RequestHash HashID = "RH" )
Hash IDs for specific object types, in lexicographic order. Hash IDs must be PREFIX-FREE (no hash ID is a prefix of another).
type Hashable ¶
Hashable is an interface implemented by an object that can be represented with a sequence of bytes to be hashed or signed, together with a type ID to distinguish different types of objects.
type VRFSecrets ¶
type VRFSecrets struct { PK VrfPubkey SK VrfPrivkey // contains filtered or unexported fields }
VRFSecrets is a wrapper for a VRF keypair. Use *VrfPrivkey instead
func GenerateVRFSecrets ¶
func GenerateVRFSecrets() *VRFSecrets
GenerateVRFSecrets is deprecated, use VrfKeygen or VrfKeygenFromSeed instead
type VrfOutput ¶
type VrfOutput [64]byte
VrfOutput is a 64-byte pseudorandom value that can be computed from a VrfProof. The VRF scheme guarantees that such output will be unique
type VrfPrivkey ¶
type VrfPrivkey [64]byte
A VrfPrivkey is a private key used for producing VRF proofs. Specifically, we use a 64-byte ed25519 private key (the latter 32-bytes are the precomputed public key)
func (VrfPrivkey) Prove ¶
func (sk VrfPrivkey) Prove(message Hashable) (proof VrfProof, ok bool)
Prove constructs a VRF Proof for a given Hashable. ok will be false if the private key is malformed.
func (VrfPrivkey) Pubkey ¶
func (sk VrfPrivkey) Pubkey() (pk VrfPubkey)
Pubkey returns the public key that corresponds to the given private key.
type VrfProof ¶
type VrfProof [80]byte
A VrfProof for a message can be generated with a secret key and verified against a public key, like a signature. Proofs are malleable, however, for a given message and public key, the VRF output that can be computed from a proof is unique.
type VrfPubkey ¶
type VrfPubkey [32]byte
A VrfPubkey is a public key that can be used to verify VRF proofs.
func VrfPubkeyFromHexString ¶
func (VrfPubkey) ToHexString ¶
func (VrfPubkey) Verify ¶
Verify checks a VRF proof of a given Hashable. If the proof is valid the pseudorandom VrfOutput will be returned. For a given public key and message, there are potentially multiple valid proofs. However, given a public key and message, all valid proofs will yield the same output. Moreover, the output is indistinguishable from random to anyone without the proof or the secret key.