Documentation ¶
Index ¶
- func GetAlgorithms() (algs []string)
- func Hash(message []byte) (*big.Int, error)
- func RegisterProvingMethod(alg string, f func() ProvingMethod)
- type HeaderKey
- type ProofInputsPreparerHandlerFunc
- type ProvingMethod
- type ProvingMethodGroth16Auth
- func (m *ProvingMethodGroth16Auth) Alg() string
- func (m *ProvingMethodGroth16Auth) CircuitID() string
- func (m *ProvingMethodGroth16Auth) Prove(inputs, provingKey, wasm []byte) (*types.ZKProof, error)
- func (m *ProvingMethodGroth16Auth) Verify(messageHash []byte, proof *types.ZKProof, verificationKey []byte) error
- type Token
- func (token *Token) CompactSerialize() (string, error)
- func (token *Token) FullSerialize() (string, error)
- func (token *Token) GetMessageHash() ([]byte, error)
- func (token *Token) GetPayload() []byte
- func (token *Token) ParsePubSignals(out circuits.PubSignalsUnmarshaller) error
- func (token *Token) Prove(provingKey, wasm []byte) (string, error)
- func (token *Token) Verify(verificationKey []byte) (bool, error)
- func (token *Token) WithHeader(key HeaderKey, value interface{}) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GetAlgorithms ¶
func GetAlgorithms() (algs []string)
GetAlgorithms returns a list of registered "alg" names
func Hash ¶
Hash returns poseidon hash of big.Int that was created from sha256 hash of the message bytes if such big.Int is not in the Field, DivMod result is returned.
func RegisterProvingMethod ¶
func RegisterProvingMethod(alg string, f func() ProvingMethod)
RegisterProvingMethod registers the "alg" name and a factory function for proving method. This is typically done during init() in the method's implementation
Types ¶
type HeaderKey ¶
type HeaderKey string
HeaderKey represents type for jwz headers keys
const ( // HeaderType is 'typ' header, so we can set specific typ HeaderType HeaderKey = "typ" // we allow to set typ of token )
type ProofInputsPreparerHandlerFunc ¶
ProofInputsPreparerHandlerFunc prepares inputs using hash message and circuit id
type ProvingMethod ¶
type ProvingMethod interface { Verify(messageHash []byte, proof *types.ZKProof, verificationKey []byte) error // Returns nil if proof is valid Prove(inputs []byte, provingKey []byte, wasm []byte) (*types.ZKProof, error) // Returns proof or error Alg() string // Returns the alg identifier for this method (example: 'AUTH-GROTH-16') CircuitID() string }
ProvingMethod can be used add new methods for signing or verifying tokens.
func GetProvingMethod ¶
func GetProvingMethod(alg string) (method ProvingMethod)
GetProvingMethod retrieves a proving method from an "alg" string
type ProvingMethodGroth16Auth ¶
type ProvingMethodGroth16Auth struct {
// contains filtered or unexported fields
}
ProvingMethodGroth16Auth defines proofs family and specific circuit
var (
ProvingMethodGroth16AuthInstance *ProvingMethodGroth16Auth
)
ProvingMethodGroth16AuthInstance instance for groth16 proving method with an auth circuit
func (*ProvingMethodGroth16Auth) Alg ¶
func (m *ProvingMethodGroth16Auth) Alg() string
Alg returns current zk alg
func (*ProvingMethodGroth16Auth) CircuitID ¶
func (m *ProvingMethodGroth16Auth) CircuitID() string
CircuitID returns name of circuit
type Token ¶
type Token struct { ZkProof *types.ZKProof // The third segment of the token. Populated when you Parse a token Alg string // fields that are part of headers CircuitID string // id of circuit that will be used for proving Method ProvingMethod // proving method to create a zkp // contains filtered or unexported fields }
Token represents a JWZ Token.
func NewWithPayload ¶
func NewWithPayload(prover ProvingMethod, payload []byte, inputsPreparer ProofInputsPreparerHandlerFunc) (*Token, error)
NewWithPayload creates a new Token with the specified proving method and payload.
func (*Token) CompactSerialize ¶
CompactSerialize returns token serialized in three parts: base64 encoded headers, payload and proof.
func (*Token) FullSerialize ¶
FullSerialize returns marshaled presentation of raw token as json string.
func (*Token) GetMessageHash ¶
GetMessageHash returns bytes of jwz message hash.
func (*Token) GetPayload ¶
GetPayload returns message payload
func (*Token) ParsePubSignals ¶
ParsePubSignals unmarshalls proof public signals to provided structure.
func (*Token) Prove ¶
Prove creates and returns a complete, proved JWZ. The token is proven using the Proving Method specified in the token.
func (*Token) WithHeader ¶
WithHeader allows to set or redefine default headers