bedrock-ledger-validator-signature
A validator for bedrock-ledger that determines if M of N digital signatures on a document satisfy the requirements defined in the the ledger's configuration.
The Validator API
- validateConfiguration(validatorConfig, callback(err))
- validate(signedDocument, validatorConfig, callback(err))
- mustValidate(signedDocument, validatorConfig, callback(err, result))
Configuration
For documentation on configuration, see config.js.
Usage Example
const brValidator = ; const validatorConfig = type: 'SignatureValidator2017' validatorFilter: type: 'ValidatorFilterByType' validatorFilterByType: 'CreateWebLedgerRecord' approvedSigner: 'did:v1:53ebca61-5687-4558-b90a-03167e4c2838' 'did:v1:be0d2a4a-583f-4a8b-98c8-73bdf046bfd1/keys/1' minimumSignaturesRequired: 1; const signedDocument = "@context": "https://w3id.org/webledger/v1" "type": "CreateWebLedgerRecord" "record": "@context": "https://w3id.org/test/v1" "id": "https://example.com/events/dd5090e9-13f0-48d1-89a3-af9ffb092fcf" "type": "Concert" "name": "Big Band Concert in New York City" "startDate": "2017-07-14T21:30" "location": "https://example.org/the-venue" "offers": "type": "Offer" "price": "13.00" "priceCurrency": "USD" "url": "https://example.com/purchase/309433" "proof": "type": "RsaSignature2018" "created": "2017-07-10T14:10:24Z" "creator": "did:v1:be0d2a4a-583f-4a8b-98c8-73bdf046bfd1/keys/1" "jws": "IyEQBDNGEMt0YMpVQgrn...HF9FZpyDlFw==" ; // when ledgers are created, or configuration changes are made, state// machines should validate the validator configuration using the// `validateConfiguration` APIbrValidator; // state machines use the `mustValidate` API to determine if this// validator is designed to operate on a particular documentbrValidator; // if the `mustValidate` API returns true, then state machines should// call the `validate` API for the eventbrValidator;