signedpacketsrv

package
v0.0.6 Latest Latest
Warning

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

Go to latest
Published: Jul 9, 2019 License: GPL-3.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const GENERICSIGV01 = "iden3.gen_sig.v0_1"

GENERICSIGV01 is the signed packet payload type for a generic signature that contains an empty data field and a string key to string value mapping as form.

View Source
const IDENASSERTV01 = "iden3.iden_assert.v0_1"

IDENASSERTV01 is the signed packet payload type for an identity assertion.

View Source
const MSGV01 = "iden3.msg.v0_1"

MSGV01 is the signed packet payload type of a signed message. The signature is only used to guarantee the origin of the message. The signature doesn't say anything about the message content. This signed packet type is used for notifications.

View Source
const SIGALGV01 = "EK256K1"

SIGALGV01 is the JWS algorithm used in SIGV01. It's ECDSA with secp256k1 and keccak.

View Source
const SIGALGV02 = "ED256BJ"
View Source
const SIGV01 = "iden3.sig.v0_1" // V01 uses SIGALGV01 = "EK256K1"

SIGV01 is the JWS type of an iden3 signed packet.

View Source
const SIGV02 = "iden3.sig.v0_2" // V02 uses SIGALGV02 = "ED256BJ"

Variables

This section is empty.

Functions

This section is empty.

Types

type IdenAssertData

type IdenAssertData struct {
	Challenge string `json:"challenge" binding:"required"`
	Timeout   int64  `json:"timeout" binding:"required"`
	Origin    string `json:"origin" binding:"required"`
}

IdenAssertData contains the data field of a signed packet of type iden3.iden_assert.v0_1

type IdenAssertForm

type IdenAssertForm struct {
	EthName         string           `json:"ethName" binding:"required"`
	ProofAssignName *core.ProofClaim `json:"proofAssignName" binding:"required"`
}

IdenAssertForm contains the form field of a signed packet of type iden3.iden_assert.v0_1

type IdenAssertResult

type IdenAssertResult struct {
	NonceObj *core.NonceObj
	EthName  *string
	Id       core.ID
}

IdenAssertResult is the result of a successfull verification of an IDENASSERTV01 payload from a signed packet. EthName will be nil if no name ownership was proved (the form field of the signed packet was nil).

type Jws

type Jws struct {
	Jws string `json:"jws" binding:"required"`
}

Jws represents a JWS (JSON Web Signature) sent over the network.

type MsgForm

type MsgForm struct {
	Type string      `json:"type" binding:"required"`
	Data interface{} `json:"data" binding:"required"`
}

type RequestIdenAssert

type RequestIdenAssert struct {
	Header RequestIdenAssertHeader `json:"header" binding:"required"`
	Body   RequestIdenAssertBody   `json:"body" binding:"required"`
}

RequestIdenAssert is a request for a signed packet with payload type IDENASSERTV01.

func NewRequestIdenAssert

func NewRequestIdenAssert(nonceDb *core.NonceDb, origin string, expireDelta int64) *RequestIdenAssert

NewRequestIdenAssert generates a signing request for a signed packet with payload type IDENASSERTV01.

type RequestIdenAssertBody

type RequestIdenAssertBody struct {
	Type string         `json:"type" binding:"required"`
	Data IdenAssertData `json:"data" binding:"required"`
}

RequestIdenAssertBody is the body request of a RequestIdenAssert.

type RequestIdenAssertHeader

type RequestIdenAssertHeader struct {
	Type string `json:"typ" binding:"required"`
}

RequestIdenAssertBody is the header request of a RequestIdenAssert.

type SigHeader

type SigHeader struct {
	Type         string  `json:"typ" binding:"required"`
	Issuer       core.ID `json:"iss" binding:"required"`
	IssuedAtTime int64   `json:"iat" binding:"required"`
	Expiration   int64   `json:"exp" binding:"required"`
	Algorithm    string  `json:"alg" binding:"required"`
}

SigHeader is the JSON Web Signature Header of a signed packet.

type SigPayload

type SigPayload struct {
	Type       string             `json:"type" binding:"required"`
	KSign      *babyjub.PublicKey `json:"ksign" binding:"required"`
	ProofKSign core.ProofClaim    `json:"proofKSign" binding:"required"`
	DataRaw    json.RawMessage    `json:"data" binding:"required"`
	Data       interface{}        `json:"-"`
	FormRaw    json.RawMessage    `json:"form" binding:"required"`
	Form       interface{}        `json:"-"`
}

SigPayload is the JSON Web Signature Payload of a signed packet.

func (SigPayload) MarshalJSON

func (p SigPayload) MarshalJSON() ([]byte, error)

MarshalJSON marshals the signed packet payload into JSON.

func (*SigPayload) UnmarshalJSON

func (p *SigPayload) UnmarshalJSON(bs []byte) error

UnmarshalJSON unmarshals the signed packet payload from a JSON.

type SignedPacket

type SignedPacket struct {
	Header      SigHeader
	Payload     SigPayload
	SignedBytes []byte
	Signature   *babyjub.SignatureComp
}

SignedPacket is a JSON Web Signature unmarshaled packet of a signed packet.

func (*SignedPacket) Marshal

func (sp *SignedPacket) Marshal() (string, error)

Marshal serializes a signed packet (that has been signed) into a string, encoding it as JWS.

func (*SignedPacket) MarshalJSON

func (sp *SignedPacket) MarshalJSON() ([]byte, error)

MarshalJSON marshals a signed packet into a Jws JSON.

func (*SignedPacket) Sign

func (sp *SignedPacket) Sign(signer signsrv.Service) error

Sign signs the signed packet with the key corresponding to addr.

func (*SignedPacket) Unmarshal

func (sp *SignedPacket) Unmarshal(s string) error

Unmarshal deserializes a signed packet (encoded as JWS) from a string.

func (*SignedPacket) UnmarshalJSON

func (sp *SignedPacket) UnmarshalJSON(bs []byte) error

UnmarshalJSON unmarshals a signed packet from a Jws JSON.

type SignedPacketSigner

type SignedPacketSigner struct {
	// contains filtered or unexported fields
}

func NewSignedPacketSigner

func NewSignedPacketSigner(signer signsrv.Service, proofKSign core.ProofClaim,
	id core.ID) *SignedPacketSigner

func (*SignedPacketSigner) NewSignGenericSigV01

func (sps *SignedPacketSigner) NewSignGenericSigV01(expireDelta int64,
	form interface{}) (*SignedPacket, error)

NewSignGenericSigV01 generates and signs a signed packet with payload type GENERICSIGV01.

func (*SignedPacketSigner) NewSignIdenAssertV01

func (sps *SignedPacketSigner) NewSignIdenAssertV01(requestIdenAssert *RequestIdenAssert,
	idenAssertForm *IdenAssertForm, expireDelta int64) (*SignedPacket, error)

NewSignIdenAssertV01 generates and signs a signed packet with payload type IDENASSERTV01. idenAssertForm may be nil if proving the ownership of a name is not desired.

func (*SignedPacketSigner) NewSignMsgV01

func (sps *SignedPacketSigner) NewSignMsgV01(expireDelta int64, msgType string,
	msg interface{}) (*SignedPacket, error)

func (*SignedPacketSigner) NewSignPacketV02 added in v0.0.5

func (sps *SignedPacketSigner) NewSignPacketV02(expireDelta int64,
	payloadType string, data interface{}, form interface{}) (*SignedPacket, error)

NewSignPacketV02 generates and signs a SIGV02 signed packet.

func (*SignedPacketSigner) SetProofKSign

func (sps *SignedPacketSigner) SetProofKSign(proofKSign core.ProofClaim)

type SignedPacketVerifier

type SignedPacketVerifier struct {
	DiscoverySrv *discoverysrv.Service
	// contains filtered or unexported fields
}

func NewSignedPacketVerifier

func NewSignedPacketVerifier(discoverySrv *discoverysrv.Service,
	nameResolverSrv *nameresolversrv.Service) *SignedPacketVerifier

func (*SignedPacketVerifier) VerifyIdenAssertV01

func (ss *SignedPacketVerifier) VerifyIdenAssertV01(nonceDb *core.NonceDb, origin string,
	jws *SignedPacket) (*IdenAssertResult, error)

VerifyIdenAssertV01 verifies an IDENASSERTV01 payload of a signed packet.

func (*SignedPacketVerifier) VerifySignedPacket

func (ss *SignedPacketVerifier) VerifySignedPacket(jws *SignedPacket) error

VerifySignedPacket verifies a signed packet.

func (*SignedPacketVerifier) VerifySignedPacketGeneric

func (ss *SignedPacketVerifier) VerifySignedPacketGeneric(jws *SignedPacket) error

VerifySignedPacketGeneric verifies a signed packet and checks that the payload type is GENERICSIGV01.

func (*SignedPacketVerifier) VerifySignedPacketIdenAssert

func (ss *SignedPacketVerifier) VerifySignedPacketIdenAssert(jws *SignedPacket, nonceDb *core.NonceDb, origin string) (*IdenAssertResult, error)

VerifySignedPacketIdenAssert verifies a signed packet and the IDENASSERTV01 payload of the signed packet.

func (*SignedPacketVerifier) VerifySignedPacketV02 added in v0.0.5

func (ss *SignedPacketVerifier) VerifySignedPacketV02(jws *SignedPacket) error

VerifySignedPacketV02 verifies a SIGV02 signed packet.

Jump to

Keyboard shortcuts

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