jcs

package
v0.5.13 Latest Latest
Warning

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

Go to latest
Published: Jun 1, 2026 License: BSD-2-Clause Imports: 7 Imported by: 1

Documentation

Overview

Package jcs implements the EdDSA Cryptosuite using JSON Canonicalization Scheme (JCS) as defined in the W3C Data Integrity EdDSA Cryptosuites v1.0 specification.

This implements the eddsa-jcs-2022 cryptosuite which uses: - JSON Canonicalization Scheme (RFC 8785) for document canonicalization - SHA-256 for hashing - Ed25519 for signatures

Reference: https://www.w3.org/TR/vc-di-eddsa/#eddsa-jcs-2022

Index

Constants

View Source
const (
	// CryptosuiteEdDSAJCS2022 is the identifier for the eddsa-jcs-2022 cryptosuite
	CryptosuiteEdDSAJCS2022 = "eddsa-jcs-2022"

	// ProofTypeDataIntegrity is the W3C Data Integrity proof type
	ProofTypeDataIntegrity = "DataIntegrityProof"
)

Variables

This section is empty.

Functions

func Canonicalize

func Canonicalize(data any) ([]byte, error)

Canonicalize applies JSON Canonicalization Scheme (RFC 8785) to the input.

Types

type DataIntegrityProof

type DataIntegrityProof struct {
	Type               string `json:"type"`
	Cryptosuite        string `json:"cryptosuite"`
	VerificationMethod string `json:"verificationMethod"`
	ProofPurpose       string `json:"proofPurpose"`
	Created            string `json:"created"`
	ProofValue         string `json:"proofValue"`
	Domain             string `json:"domain,omitempty"`
	Challenge          string `json:"challenge,omitempty"`
}

DataIntegrityProof represents a W3C Data Integrity proof.

type SignOptions

type SignOptions struct {
	VerificationMethod string
	ProofPurpose       string
	Created            time.Time
	Domain             string
	Challenge          string
}

SignOptions contains options for creating a Data Integrity proof.

type Suite

type Suite struct{}

Suite implements the eddsa-jcs-2022 cryptosuite for W3C Data Integrity proofs.

func NewSuite

func NewSuite() *Suite

NewSuite creates a new eddsa-jcs-2022 cryptosuite instance.

func (*Suite) Sign

func (s *Suite) Sign(document any, key ed25519.PrivateKey, opts *SignOptions) (map[string]any, error)

Sign creates a Data Integrity proof for a JSON document using eddsa-jcs-2022.

func (*Suite) Verify

func (s *Suite) Verify(document any, publicKey ed25519.PublicKey) error

Verify verifies an eddsa-jcs-2022 Data Integrity proof on a document.

func (*Suite) VerifyWithProof

func (s *Suite) VerifyWithProof(document map[string]any, proof map[string]any, publicKey ed25519.PublicKey) error

VerifyWithProof verifies a document with a specific proof object.

Jump to

Keyboard shortcuts

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