proof

package
v0.9.3 Latest Latest
Warning

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

Go to latest
Published: Aug 11, 2026 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// IMProofRelationshipAuthentication binds request-level IM proofs to DID authentication.
	IMProofRelationshipAuthentication = "authentication"
	// IMProofRelationshipAssertionMethod binds assertion-style IM proofs to DID assertionMethod.
	IMProofRelationshipAssertionMethod = "assertionMethod"
)
View Source
const (
	ObjectProofPurpose                  = "assertionMethod"
	ObjectProofSignatureMultibasePrefix = "z"
)
View Source
const (
	ProofTypeSecp256k1     = "EcdsaSecp256k1Signature2019"
	ProofTypeEd25519       = "Ed25519Signature2020"
	ProofTypeDataIntegrity = "DataIntegrityProof"

	CryptosuiteEddsaJCS2022        = "eddsa-jcs-2022"
	CryptosuiteDidWbaSecp256k12025 = "didwba-jcs-ecdsa-secp256k1-2025"
)
View Source
const GroupReceiptProofPurpose = "assertionMethod"
View Source
const RFC9421OriginProofDefaultLabel = "sig1"

Variables

View Source
var DidWbaBindingRequiredFields = []string{
	"agent_did",
	"verification_method",
	"leaf_signature_key_b64u",
	"issued_at",
	"expires_at",
}
View Source
var GroupReceiptRequiredFields = []string{
	"receipt_type",
	"group_did",
	"group_state_version",
	"subject_method",
	"operation_id",
	"actor_did",
	"accepted_at",
	"payload_digest",
}
View Source
var IMProofDefaultComponents = []string{"@method", "@target-uri", "content-digest"}
View Source
var ObjectProofRequiredFields = []string{
	"type",
	"cryptosuite",
	"verificationMethod",
	"proofPurpose",
	"created",
	"proofValue",
}
View Source
var RFC9421OriginProofDefaultComponents = []string{"@method", "@target-uri", "content-digest"}

Functions

func BuildIMContentDigest

func BuildIMContentDigest(payload []byte) string

BuildIMContentDigest builds a content-digest header value for IM payloads.

func BuildIMSignatureInput

func BuildIMSignatureInput(keyID string, options IMGenerationOptions) (string, error)

BuildIMSignatureInput builds an IM signature-input value.

func BuildLogicalTargetURI added in v0.8.0

func BuildLogicalTargetURI(targetKind TargetKind, targetDID string) (string, error)

BuildLogicalTargetURI builds the ANP logical target URI for origin proof.

func BuildRFC9421OriginSignatureBase added in v0.8.0

func BuildRFC9421OriginSignatureBase(method string, logicalTargetURI string, contentDigest string, signatureInput string) ([]byte, error)

BuildRFC9421OriginSignatureBase builds the RFC 9421 application-layer signature base.

func CanonicalizeSignedRequestObject added in v0.8.0

func CanonicalizeSignedRequestObject(value SignedRequestObject) ([]byte, error)

CanonicalizeSignedRequestObject canonicalizes the shared signed request object with JCS semantics.

func DecodeIMSignature

func DecodeIMSignature(signature string) (string, []byte, error)

DecodeIMSignature decodes a structured or bare signature value.

func EncodeIMSignature

func EncodeIMSignature(signatureBytes []byte, label string) string

EncodeIMSignature encodes signature bytes into structured signature syntax.

func GenerateDidWbaBinding added in v0.8.2

func GenerateDidWbaBinding(agentDID string, verificationMethod string, leafSignatureKeyB64U string, privateKey anp.PrivateKeyMaterial, issuedAt string, expiresAt string, proofCreated string) (map[string]any, error)

GenerateDidWbaBinding creates and signs a strict did:wba binding object.

func GenerateGroupReceiptProof

func GenerateGroupReceiptProof(receipt map[string]any, privateKey anp.PrivateKeyMaterial, verificationMethod string) (map[string]any, error)

GenerateGroupReceiptProof signs a group receipt object.

func GenerateObjectProof added in v0.8.2

func GenerateObjectProof(document map[string]any, privateKey anp.PrivateKeyMaterial, verificationMethod string, issuerDID string, created string) (map[string]any, error)

GenerateObjectProof signs a strict Appendix-B object proof.

func GenerateW3CProof

func GenerateW3CProof(document map[string]any, privateKey anp.PrivateKeyMaterial, verificationMethod string, options GenerationOptions) (map[string]any, error)

GenerateW3CProof signs a JSON object and injects its proof object.

func VerifyDidWbaBinding added in v0.8.2

func VerifyDidWbaBinding(binding map[string]any, issuerDocument map[string]any, options DidWbaBindingVerificationOptions) error

VerifyDidWbaBinding verifies a strict did:wba binding object.

func VerifyGroupReceiptProof

func VerifyGroupReceiptProof(receipt map[string]any, issuerDocument map[string]any) error

VerifyGroupReceiptProof verifies a signed group receipt.

func VerifyIMContentDigest

func VerifyIMContentDigest(payload []byte, contentDigest string) bool

VerifyIMContentDigest verifies a content-digest value.

func VerifyW3CProof

func VerifyW3CProof(document map[string]any, publicKey anp.PublicKeyMaterial, options VerificationOptions) bool

VerifyW3CProof returns true when proof verification succeeds.

func VerifyW3CProofDetailed

func VerifyW3CProofDetailed(document map[string]any, publicKey anp.PublicKeyMaterial, options VerificationOptions) error

VerifyW3CProofDetailed verifies a W3C proof and returns an error on failure.

Types

type DidWbaBindingVerificationOptions added in v0.8.2

type DidWbaBindingVerificationOptions struct {
	Now                        string
	ExpectedLeafSignatureKey   string
	ExpectedCredentialIdentity string
}

DidWbaBindingVerificationOptions configures business checks around did:wba bindings.

type Error

type Error struct {
	Message string
}

Error reports proof generation or verification failures.

func (*Error) Error

func (e *Error) Error() string

Error implements error.

type GenerationOptions

type GenerationOptions struct {
	ProofPurpose string
	ProofType    string
	Cryptosuite  string
	Created      string
	Domain       string
	Challenge    string
}

GenerationOptions configures W3C proof generation.

type IMGenerationOptions

type IMGenerationOptions struct {
	Label      string
	Components []string
	Created    *int64
	Expires    *int64
	Nonce      string
}

IMGenerationOptions configures IM proof generation.

type IMProof

type IMProof struct {
	ContentDigest  string `json:"contentDigest"`
	SignatureInput string `json:"signatureInput"`
	Signature      string `json:"signature"`
}

IMProof stores an ANP IM business proof.

func GenerateIMProof

func GenerateIMProof(payload []byte, signatureBase []byte, privateKey anp.PrivateKeyMaterial, keyID string, options IMGenerationOptions) (IMProof, error)

GenerateIMProof signs a prepared signature base and payload digest.

type IMVerificationResult

type IMVerificationResult struct {
	ParsedSignatureInput ParsedIMSignatureInput `json:"parsed_signature_input"`
	VerificationMethod   map[string]any         `json:"verification_method"`
}

IMVerificationResult contains the verified verification method.

func VerifyIMProofWithDocument

func VerifyIMProofWithDocument(proof IMProof, payload []byte, signatureBase []byte, didDocument map[string]any, expectedSignerDID string) (IMVerificationResult, error)

VerifyIMProofWithDocument verifies an IM proof using a DID document.

func VerifyIMProofWithDocumentForRelationship

func VerifyIMProofWithDocumentForRelationship(proof IMProof, payload []byte, signatureBase []byte, didDocument map[string]any, expectedSignerDID string, verificationRelationship string) (IMVerificationResult, error)

VerifyIMProofWithDocumentForRelationship verifies an IM proof using a DID document and an explicit verification relationship.

func VerifyIMProofWithVerificationMethod

func VerifyIMProofWithVerificationMethod(proof IMProof, payload []byte, signatureBase []byte, verificationMethod map[string]any, expectedSignerDID string) (IMVerificationResult, error)

VerifyIMProofWithVerificationMethod verifies an IM proof with an explicit verification method.

func VerifyRFC9421OriginProof added in v0.8.0

func VerifyRFC9421OriginProof(originProof RFC9421OriginProof, method string, meta map[string]any, body map[string]any, options RFC9421OriginProofVerificationOptions) (IMVerificationResult, error)

VerifyRFC9421OriginProof verifies an origin proof against protocol fields.

type ObjectProofVerificationResult added in v0.8.2

type ObjectProofVerificationResult struct {
	IssuerDID            string         `json:"issuer_did"`
	VerificationMethodID string         `json:"verification_method_id"`
	VerificationMethod   map[string]any `json:"verification_method"`
}

ObjectProofVerificationResult captures successful Appendix-B proof verification output.

func VerifyObjectProof added in v0.8.2

func VerifyObjectProof(document map[string]any, issuerDID string, issuerDocument map[string]any) (ObjectProofVerificationResult, error)

VerifyObjectProof verifies a strict Appendix-B object proof against the issuer DID document.

type ParsedIMSignatureInput

type ParsedIMSignatureInput struct {
	Label           string   `json:"label"`
	Components      []string `json:"components"`
	SignatureParams string   `json:"signature_params"`
	KeyID           string   `json:"keyid"`
	Nonce           string   `json:"nonce,omitempty"`
	Created         *int64   `json:"created,omitempty"`
	Expires         *int64   `json:"expires,omitempty"`
}

ParsedIMSignatureInput is the parsed signature-input structure.

func ParseIMSignatureInput

func ParseIMSignatureInput(signatureInput string) (ParsedIMSignatureInput, error)

ParseIMSignatureInput parses a signature-input string.

type RFC9421OriginProof added in v0.8.0

type RFC9421OriginProof struct {
	ContentDigest  string `json:"contentDigest"`
	SignatureInput string `json:"signatureInput"`
	Signature      string `json:"signature"`
}

RFC9421OriginProof is the high-level origin proof payload defined by ANP P1 Appendix A.

func GenerateRFC9421OriginProof added in v0.8.0

func GenerateRFC9421OriginProof(method string, meta map[string]any, body map[string]any, privateKey anp.PrivateKeyMaterial, keyID string, options RFC9421OriginProofGenerationOptions) (RFC9421OriginProof, error)

GenerateRFC9421OriginProof builds and signs an origin proof from protocol fields.

type RFC9421OriginProofGenerationOptions added in v0.8.0

type RFC9421OriginProofGenerationOptions struct {
	Created *int64
	Expires *int64
	Nonce   string
	Label   string
}

RFC9421OriginProofGenerationOptions configures high-level origin proof generation.

type RFC9421OriginProofVerificationOptions added in v0.8.0

type RFC9421OriginProofVerificationOptions struct {
	DidDocument        map[string]any
	VerificationMethod map[string]any
	ExpectedSignerDID  string
}

RFC9421OriginProofVerificationOptions configures high-level origin proof verification.

type SignedRequestObject added in v0.8.0

type SignedRequestObject struct {
	Method string         `json:"method"`
	Meta   map[string]any `json:"meta"`
	Body   map[string]any `json:"body"`
}

SignedRequestObject is the shared business object defined by ANP P1 Appendix A.

func BuildSignedRequestObject added in v0.8.0

func BuildSignedRequestObject(method string, meta map[string]any, body map[string]any) (SignedRequestObject, error)

BuildSignedRequestObject builds the shared signed request object.

type TargetKind added in v0.8.0

type TargetKind string
const (
	TargetKindAgent   TargetKind = "agent"
	TargetKindGroup   TargetKind = "group"
	TargetKindService TargetKind = "service"
)

type VerificationOptions

type VerificationOptions struct {
	ExpectedPurpose   string
	ExpectedDomain    string
	ExpectedChallenge string
}

VerificationOptions configures W3C proof verification.

Jump to

Keyboard shortcuts

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