envelope

package
v0.1.6 Latest Latest
Warning

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

Go to latest
Published: Dec 15, 2021 License: ISC Imports: 7 Imported by: 15

Documentation

Overview

Package envelope supports the JSON Envelope Spec It can be found here https://github.com/bitcoin-sv-specs/brfc-misc/tree/master/jsonenvelope

Standard for serialising a JSON document in order to have consistency when ECDSA signing the document. Any changes to a document being signed and verified, however minor they may be, will cause the signature verification to fail since the document will be converted into a string before being (hashed and then) signed. With JSON documents, the format permits changes to be made without compromising the validity of the format (eg. extra spaces, carriage returns, etc.).

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type JSONEnvelope

type JSONEnvelope struct {
	Payload   string  `json:"payload"`
	Signature *string `json:"signature"`
	PublicKey *string `json:"publicKey"`
	Encoding  string  `json:"encoding"`
	MimeType  string  `json:"mimetype"`
}

JSONEnvelope defines an envelop contain option signature and public key to use to verify the signature and payload. If no Signature or PublicKey are provided we do not validate the payload. The payload is usually an escaped JSON string.

func NewJSONEnvelope

func NewJSONEnvelope(payload interface{}) (*JSONEnvelope, error)

NewJSONEnvelope will create and return a new JSONEnvelope with the provided payload serialised and signed.

func (*JSONEnvelope) IsValid

func (j *JSONEnvelope) IsValid() (bool, error)

IsValid will check that a JSONEnvelope is valid by using the PublicKey and Signature to validate the payload. If the payload differs from the signature, false is returned. If the signature or public key are invalid an error is returned.

Jump to

Keyboard shortcuts

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