1.0.1 • Published 4 years ago

@bloomprotocol/attestations-common v1.0.1

Weekly downloads
25
License
Apache-2.0
Repository
github
Last release
4 years ago

Attestations Commons Kit

Shared types and utility functions for attestation related kits

Installation

npm install --save @bloomprotocol/att-comm-kit

Extrator

The extractor function helps extract data from a verifiable credential.

import {IVerifiableCredential, extract} from '@bloomprotocol/attestations-common'

const emailCredential: IVerifiableCredential = {...}

const emailData = extract(emailCredential.credentialSubject.data, 'email', 'email')

AttestationData

import {AttestationData} from '@bloomprotocol/attestations-common'

We define some extensible interfaces that the attestation data will be formatted in. These are use when extracting the data from the VC.

EthUtils

Utilty functions for dealing with ethereum and general crypto

Utils

General purpose utily functions

RFC3339 DateTime

Validation

Types

Types for Verifiable Presentations, Verifiable Credentials, and Verifiable Auth

Verifiable Credential

Format of a users verified credential

NameDescriptionType
idIdentifier for this credential`string`
typeType name of the credential`string`
issuerIdentifier of the entity that issued the credential`string`
issuanceDateRFC3339 Datetime of when the credential was issued`string`
credentialSubjectInformation about the subject of the credential and the verified data`CredentialSubject`
proofCredential proof showing the issuer signed the credential being shared`CredentialProof`

Credential Subject

Information identifying the subject and data of the credential

NameDescriptionType
subjectIdentifier of original subject of the attestation (Eth Address/ DID)`string`
dataStringified data containing what was verified and approved for sharing`string`
authorizationOptional array of signatures showing chain of custody between original credential subject and current holder`Authorization[]`

Authorization

Optional array of signatures showing chain of custody between original credential subject and current holder

NameDescriptionType
subjectAddress of keypair granting authorization`string`
recipientAddress of keypair receiving authorization`string`
revocationHex string to identify this authorization in event of revocation`string`
signatureHash of subject, recipient, revocation signed by subject pk`string`

Credential Proof

Information identifying the subject and data of the credential

NameDescriptionType
typeIdentifier of this proof type`string`
createdRFC3339 Datetime of when this proof was created. Usually same as issuance date`string`
creatorIdentifier of attester. Eth address or DID`string`
dataProof object containing all data necessary to validate original attestation`VerifiedData`

Verified Data

Proof defined by the Selective Disclosure Merkle Tree Spec

There are three types of Verified Data proofs in the spec

NameDescription
Batch ProofProof structure which enables submitting batches of attestations at the same time in a single transaction
On Chain ProofProof structure intended for use with the AttestationLogic smart contract
Legacy ProofLegacy proof structure similar to On Chain proof. Used with Attestation Logic smart contract

This linked diagram shows how the proof data structures are formed

Batch Proof

NameDescriptionType
versionIdentifier of this proof type`string`
batchLayer2HashAttestation hash formed by hashing subject sig with attester sig`string`
batchAttesterSigAttester's signature of layer2Hash and subject address`string`
subjectSigSubject signature of attestation agreement`string`
requestNonceNonce used in subjectSig`string`
layer2HashHash of rootHash and rootHashNonce`string`
rootHashMerkle tree root hash`string`
rootHashNonceNonce used with rootHash to create layer2Hash`string`
proofArray of merkle proof objects`MerkleProof`
stagemainnet, rinkeby, local, etc`string`
targetNode of the merkle tree being shared`SignedClaimNode`
attesterAttester Eth address`string`
subjectSubject Eth address`string`

On Chain Proof

NameDescriptionType
versionIdentifier of this proof type`string`
txEthereum transaction which refrences this attestation`string`
layer2HashHash of rootHash and rootHashNonce`string`
rootHashMerkle tree root hash`string`
rootHashNonceNonce used with rootHash to create layer2Hash`string`
proofArray of merkle proof objects`MerkleProof`
stagemainnet, rinkeby, local, etc`string`
targetNode of the merkle tree being shared`SignedClaimNode`
attesterAttester Eth address`string`

Legacy Proof

NameDescriptionType
versionIdentifier of this proof type`string`
txEthereum transaction which refrences this attestation`string`
layer2HashHash of rootHash and rootHashNonce`string`
rootHashMerkle tree root hash`string`
rootHashNonceNonce used with rootHash to create layer2Hash`string`
proofArray of merkle proof objects`MerkleProof`
stagemainnet, rinkeby, local, etc`string`
targetNode of the merkle tree being shared`LegacyDataNode`
attesterAttester Eth address`string`

Signed Claim Node

Format of target attestation data

NameDescriptionType
claimNodeObject representing the attestation data, type, and revocation links`IssuedClaimNode`
attesterAttester Eth address`string`
attesterSigRoot hash of claim node tree signed by attester`string`

Issued Claim Node

Format of attestation node

NameDescriptionType
dataObject containing the data, nonce, and version of the attestation`AttestationData`
typeObject containing he type, nonce, and optionally a provider of the attestation`AttestationType`
auxString containing a hash of an `IAuxSig` object or just a padding node hash`string`
issuanceObject containing issuance and revocation metadata`IssuanceNode`

Issuance Node

NameDescriptionType
localRevocationTokenHex string to be used in public revocation registry to revoke this data node`string`
globalRevocationTokenHex string to be used in public revocation registry to revoke this entire attestation`string`
dataHashHash of claim tree`string`
typeHashHash of type object`string`
issuanceDateRFC3339 datetime of when this claim was issued`string`
expirationDateRFC3339 datetime of when this claim should be considered expired`string`

Legacy Data Node

Format of legacy attestation data

NameDescriptionType
attestationNodeObject representing the attestation data, type, and revocation links`LegacyAttestationNode`
signedAttestationRoot hash of attestation tree signed by attester`string`

Legacy Attestation Node

NameDescriptionType
dataObject containing the data, nonce, and version of the attestation`AttestationData`
typeObject containing he type, nonce, and optionally a provider of the attestation`AttestationType`
auxString containing a hash of an `IAuxSig` object or just a padding node hash`string`
linkObject containing the information used in the event of an attestation revocation`RevocationLinks`

Merkle Proof

Format of proof object used to perform merkle proof

NameDescriptionType
position`left` or `right` indicating position of hash in merkle tree`string`
dataHex string of node hash`string`

Presentation Proof

Format of a users verified data

NameDescriptionType
typeIdentifier of this type of presentation proof`string`
createdRFC3339 datetime of when this proof was generated and signed`string`
creatorIdentifier of holder sharing the credential. Eth address or DID`string`
nonceToken used to make this request unique`string`
domainWebsite of recipient where user intends to share the data`string`
credentialHashHash of array of layer2Hashes being shared`string`

Authentication Proof

Format of a users verified data

NameDescriptionType
typeIdentifier of this type of presentation proof`string`
createdRFC3339 datetime of when this proof was generated and signed`string`
creatorIdentifier of holder sharing the credential. Eth address or DID`string`
nonceToken used to make this request unique`string`
domainWebsite of recipient where user intends to share the data`string`

AttestationTypes

Some helper types and functions for dealing with attestation types ('email', 'phone', 'pep', etc.)