Documentation ¶
Index ¶
- Variables
- type Condition
- func DecodeCondition(encodedCondition []byte) (*Condition, error)
- func NewCompoundCondition(conditionType ConditionType, fingerprint []byte, cost int, ...) *Condition
- func NewSimpleCondition(conditionType ConditionType, fingerprint []byte, cost int) *Condition
- func ParseURI(uri string) (*Condition, error)
- type ConditionType
- type ConditionTypeSet
- type FfEd25519Sha256
- func (f FfEd25519Sha256) Condition() *Condition
- func (f FfEd25519Sha256) ConditionType() ConditionType
- func (f FfEd25519Sha256) Cost() int
- func (f FfEd25519Sha256) Ed25519PublicKey() ed25519.PublicKey
- func (f FfEd25519Sha256) Encode() ([]byte, error)
- func (f FfEd25519Sha256) Validate(condition *Condition, message []byte) error
- type FfPrefixSha256
- func (f FfPrefixSha256) Condition() *Condition
- func (f FfPrefixSha256) ConditionType() ConditionType
- func (f FfPrefixSha256) Cost() int
- func (f FfPrefixSha256) Encode() ([]byte, error)
- func (f FfPrefixSha256) IsFulfilled() bool
- func (f FfPrefixSha256) SubCondition() *Condition
- func (f FfPrefixSha256) Validate(condition *Condition, message []byte) error
- type FfPreimageSha256
- type FfRsaSha256
- type FfThresholdSha256
- type Fulfillment
Constants ¶
This section is empty.
Variables ¶
var ASN1Context *asn1.Context
ASN1Context defines the ASN.1 context that is used to encode and decode objects. It explicitly requires encoding and decoding to happen in strict DER format and it also defines the CHOICE mapping for fulfillments (`fulfillment`) and conditions (`condition`).
Functions ¶
This section is empty.
Types ¶
type Condition ¶
type Condition struct {
// contains filtered or unexported fields
}
Condition represents a crypto-condition.
func DecodeCondition ¶
DecodeCondition decodes the DER encoding of a condition.
func NewCompoundCondition ¶
func NewCompoundCondition(conditionType ConditionType, fingerprint []byte, cost int, subTypes ConditionTypeSet) *Condition
NewCompoundCondition constructs a new compound condition with subtypes.
func NewSimpleCondition ¶
func NewSimpleCondition(conditionType ConditionType, fingerprint []byte, cost int) *Condition
NewSimpleCondition constructs a new simple condition.
func (Condition) Fingerprint ¶
Fingerprint returns the fingerprint of this condition.
func (Condition) SubTypes ¶
func (c Condition) SubTypes() ConditionTypeSet
SubTypes returns the condition types of the sub-conditions of this condition.
func (Condition) Type ¶
func (c Condition) Type() ConditionType
Type returns the type of this condition.
type ConditionType ¶
type ConditionType int
ConditionType represent one of the predefined condition types in the specification.
const ( // PREIMAGE-SHA-256 CTPreimageSha256 ConditionType = iota // PREFIX-SHA-256 CTPrefixSha256 // THRESHOLD-SHA-256 CTThresholdSha256 // RSA-SHA-256 CTRsaSha256 // ED25519 CTEd25519Sha256 )
All the condition types and their corresponding type codes.
func (ConditionType) IsCompound ¶
func (t ConditionType) IsCompound() bool
IsCompound returns true for compound condition types that have subtypes.
func (ConditionType) String ¶
func (t ConditionType) String() string
type ConditionTypeSet ¶
ConditionTypeSet represents a set of ConditionTypes. It is represented as an ASN.1 BIT STRING like defined in the specification.
func (ConditionTypeSet) AllTypes ¶
func (c ConditionTypeSet) AllTypes() []ConditionType
func (ConditionTypeSet) Equals ¶
func (c ConditionTypeSet) Equals(other ConditionTypeSet) bool
Equals returns true if `other` represents the same condition type set as this. False otherwise.
func (ConditionTypeSet) Has ¶
func (c ConditionTypeSet) Has(conditionType ConditionType) bool
Has determines if the given condition type is present.
type FfEd25519Sha256 ¶
FfEd25519Sha256 implements the ED25519-SHA-256 fulfillment.
func NewEd25519Sha256 ¶
func NewEd25519Sha256(pubkey []byte, signature []byte) (*FfEd25519Sha256, error)
NewEd25519Sha256 creates a new ED25519-SHA-256 fulfillment.
func (FfEd25519Sha256) Condition ¶
func (f FfEd25519Sha256) Condition() *Condition
func (FfEd25519Sha256) ConditionType ¶
func (f FfEd25519Sha256) ConditionType() ConditionType
func (FfEd25519Sha256) Cost ¶
func (f FfEd25519Sha256) Cost() int
func (FfEd25519Sha256) Ed25519PublicKey ¶
func (f FfEd25519Sha256) Ed25519PublicKey() ed25519.PublicKey
Ed25519PublicKey returns the Ed25519 public key.
func (FfEd25519Sha256) Encode ¶
func (f FfEd25519Sha256) Encode() ([]byte, error)
type FfPrefixSha256 ¶
type FfPrefixSha256 struct { Prefix []byte `asn1:"tag:0"` MaxMessageLength uint32 `asn1:"tag:1"` // Only have either a sub-fulfillment or a sub-condition. SubFulfillment Fulfillment `asn1:"tag:2,explicit,choice:fulfillment"` // contains filtered or unexported fields }
FfPrefixSha256 implements the PREFIX-SHA-256 fulfillment.
func NewPrefixSha256 ¶
func NewPrefixSha256(prefix []byte, maxMessageLength uint32, subFf Fulfillment) *FfPrefixSha256
NewPrefixSha256 creates a new PREFIX-SHA-256 fulfillment.
func NewPrefixSha256Unfulfilled ¶
func NewPrefixSha256Unfulfilled(prefix []byte, maxMessageLength uint32, subCondition *Condition) *FfPrefixSha256
PrefixSha256Unfulfilled creates an unfulfilled PREFIX-SHA-256 fulfillment.
func (FfPrefixSha256) Condition ¶
func (f FfPrefixSha256) Condition() *Condition
func (FfPrefixSha256) ConditionType ¶
func (f FfPrefixSha256) ConditionType() ConditionType
func (FfPrefixSha256) Cost ¶
func (f FfPrefixSha256) Cost() int
func (FfPrefixSha256) Encode ¶
func (f FfPrefixSha256) Encode() ([]byte, error)
func (FfPrefixSha256) IsFulfilled ¶
func (f FfPrefixSha256) IsFulfilled() bool
IsFulfilled returns true if this fulfillment is fulfilled, i.e. when it contains a sub-fulfillment. If false, it only contains a sub-condition.
func (FfPrefixSha256) SubCondition ¶
func (f FfPrefixSha256) SubCondition() *Condition
SubCondition returns the sub-condition of this fulfillment.
type FfPreimageSha256 ¶
type FfPreimageSha256 struct {
Preimage []byte `asn1:"tag:0"`
}
FfPreimageSha256 implements the PREIMAGE-SHA-256 fulfillment.
func NewPreimageSha256 ¶
func NewPreimageSha256(preimage []byte) *FfPreimageSha256
NewPreimageSha256 creates a new PREIMAGE-SHA-256 fulfillment.
func (FfPreimageSha256) Condition ¶
func (f FfPreimageSha256) Condition() *Condition
func (FfPreimageSha256) ConditionType ¶
func (f FfPreimageSha256) ConditionType() ConditionType
func (FfPreimageSha256) Cost ¶
func (f FfPreimageSha256) Cost() int
func (FfPreimageSha256) Encode ¶
func (f FfPreimageSha256) Encode() ([]byte, error)
type FfRsaSha256 ¶
NewFfRsaSha256 implements the RSA-SHA-256 fulfillment.
func NewRsaSha256 ¶
func NewRsaSha256(modulus []byte, signature []byte) (*FfRsaSha256, error)
RsaSha256 creates a new RSA-SHA-256 fulfillment.
func (FfRsaSha256) Condition ¶
func (f FfRsaSha256) Condition() *Condition
func (FfRsaSha256) ConditionType ¶
func (f FfRsaSha256) ConditionType() ConditionType
func (FfRsaSha256) Cost ¶
func (f FfRsaSha256) Cost() int
func (FfRsaSha256) Encode ¶
func (f FfRsaSha256) Encode() ([]byte, error)
func (FfRsaSha256) PublicKey ¶
func (f FfRsaSha256) PublicKey() *rsa.PublicKey
PublicKey returns the RSA public key.
type FfThresholdSha256 ¶
type FfThresholdSha256 struct { Threshold uint16 `asn1:"-"` SubFulfillments []Fulfillment `asn1:"tag:0,explicit,set,choice:fulfillment"` SubConditions []*Condition `asn1:"tag:1,explicit,set,choice:condition"` }
FfThresholdSha256 implements the THRESHOLD-SHA-256 fulfillment. This type of fulfillment is currently not supported.
func NewThresholdSha256 ¶
func NewThresholdSha256(threshold uint16, subFulfillments []Fulfillment, subConditions []*Condition) *FfThresholdSha256
NewThresholdSha256 creates a new THRESHOLD-SHA-256 fulfillment. This type of fulfillment is currently not supported.
func (FfThresholdSha256) Condition ¶
func (f FfThresholdSha256) Condition() *Condition
func (FfThresholdSha256) ConditionType ¶
func (f FfThresholdSha256) ConditionType() ConditionType
func (FfThresholdSha256) Cost ¶
func (f FfThresholdSha256) Cost() int
func (FfThresholdSha256) Encode ¶
func (f FfThresholdSha256) Encode() ([]byte, error)
type Fulfillment ¶
type Fulfillment interface { // ConditionType returns the type of condition this fulfillment fulfills. ConditionType() ConditionType // Condition generates the condition that this fulfillment fulfills. Condition() *Condition // Cost calculates the cost metric of this fulfillment. Cost() int // Encode encodes the fulfillment into binary format. Encode() ([]byte, error) // Validate checks whether this fulfillment correctly validates the given // condition using the specified message. // It returns nil if it does, an error indicating the problem otherwise. Validate(*Condition, []byte) error // contains filtered or unexported methods }
Fulfillment defines the fulfillment interface.
func DecodeFulfillment ¶
func DecodeFulfillment(encodedFulfillment []byte) (Fulfillment, error)
DecodeFulfillment decodes the DER encoding of a fulfillment.