Skip to content

xpring-eng/xrpl-validator-domains

Repository files navigation

xrpl-validator-domains

Verify the domain names of XRP Ledger validators, in accordance with domain verification

Usage

To verify manifest signatures and domains, use the verifyValidatorDomain() method.

API

Node.js

Install using npm or yarn.

npm install xrpl-validator-domains --save
import { verifyValidatorDomain, verifyManifestSignature } from 'xrpl-validator-domains'

Browser

<script type="text/javascript" src="https://unpkg.com/[email protected]/build/xrpl-validator-domains-min.js"></script>
<script> const {verifyManifestSignature, verifyValidatorDomain} = window.verifyDomain </script>

verifyValidatorDomain(manifest)

Parse and verify a hex-string manifest. Various manifest formats are supported. The following examples show the supported manifest formats, as well as the structure of the returned object:

> await verifyValidatorDomain("240000007B7121EDA54C85F91219FD259134B6B126AD64AE7204B81DD4052510657E1A5697246AD27321032F7ACF6D67C42C9C898F576F92FE4638EB6C88D0DC7F6710AF00ED6BF50D97D676473045022100BE0B2E6071AED53C19A76BDC6EDE1A351C35343AA7CF917587F93C9D85C5A7B702207135F72654DC3AD70FE8A4DEB128965268A312DFB3E9A7C68BA8E9A8931F4285770F7261626269746B69636B2E636C7562701240C4FF2A6D277D24DEFB1C1EDF67285171EA02DC035FEF6216DEE41019CE41611AD4430AF59938DC505E538CCF669D521AC2A456C3805FE3CA85BB10B2A691B50B")
> {
  verified: true,
  message: 'rabbitkick.club has been verified',
  manifest: {
    Sequence: 123,
    Signature: '3045022100BE0B2E6071AED53C19A76BDC6EDE1A351C35343AA7CF917587F93C9D85C5A7B702207135F72654DC3AD70FE8A4DEB128965268A312DFB3E9A7C68BA8E9A8931F4285',
    MasterSignature: 'C4FF2A6D277D24DEFB1C1EDF67285171EA02DC035FEF6216DEE41019CE41611AD4430AF59938DC505E538CCF669D521AC2A456C3805FE3CA85BB10B2A691B50B',
    Domain: 'rabbitkick.club',
    PublicKey: 'nHUcNC5ni7XjVYfCMe38Rm3KQaq27jw7wJpcUYdo4miWwpNePRTw',
    SigningPubKey: 'n9Li9iXepgXECvTFq2hGoxqSttJy9rrC1NbZ75NXLZyKFekV5ZU1'
  }
}
> await verifyValidatorDomain({
    Sequence: 123,
    Signature: '3045022100BE0B2E6071AED53C19A76BDC6EDE1A351C35343AA7CF917587F93C9D85C5A7B702207135F72654DC3AD70FE8A4DEB128965268A312DFB3E9A7C68BA8E9A8931F4285',
    MasterSignature: 'C4FF2A6D277D24DEFB1C1EDF67285171EA02DC035FEF6216DEE41019CE41611AD4430AF59938DC505E538CCF669D521AC2A456C3805FE3CA85BB10B2A691B50B',
    Domain: 'rabbitkick.club',
    PublicKey: 'nHUcNC5ni7XjVYfCMe38Rm3KQaq27jw7wJpcUYdo4miWwpNePRTw',
    SigningPubKey: 'n9Li9iXepgXECvTFq2hGoxqSttJy9rrC1NbZ75NXLZyKFekV5ZU1'
  })
> {
  verified: true,
  message: 'rabbitkick.club has been verified',
  manifest: {
    Sequence: 123,
    Signature: '3045022100BE0B2E6071AED53C19A76BDC6EDE1A351C35343AA7CF917587F93C9D85C5A7B702207135F72654DC3AD70FE8A4DEB128965268A312DFB3E9A7C68BA8E9A8931F4285',
    MasterSignature: 'C4FF2A6D277D24DEFB1C1EDF67285171EA02DC035FEF6216DEE41019CE41611AD4430AF59938DC505E538CCF669D521AC2A456C3805FE3CA85BB10B2A691B50B',
    Domain: 'rabbitkick.club',
    PublicKey: 'nHUcNC5ni7XjVYfCMe38Rm3KQaq27jw7wJpcUYdo4miWwpNePRTw',
    SigningPubKey: 'n9Li9iXepgXECvTFq2hGoxqSttJy9rrC1NbZ75NXLZyKFekV5ZU1'
  }
}
> await verifyValidatorDomain({
    seq: 2,
    domain: "payid.mayurbhandary.com",
    master_key: "nHBd6ZRXfG353vtK1kwCahqbMk6BAqUz57rVy77Do5YTBG8LHkye",
    signing_key: "n9KqxB1nyphLfQnj8YBWtwt9ekhM58QQR3UWG3bRFKofSvBUDhXu",
    signature: "3045022100A887F4C261786803AD033839FB52272E1123A57DFF48C07C06616D2028A4CC0502203F3325B1635864EBBFE44991910D66836F66FC00E14E965AB0F5352AD97816FF",
    master_signature: "1234567890ABCDEF",
    type: "manifestReceived"
})
> {
  verified: false,
  message: 'Cannot verify manifest signature',
  manifest: {
    seq: 2,
    domain: 'payid.mayurbhandary.com',
    master_key: 'nHBd6ZRXfG353vtK1kwCahqbMk6BAqUz57rVy77Do5YTBG8LHkye',
    signing_key: 'n9KqxB1nyphLfQnj8YBWtwt9ekhM58QQR3UWG3bRFKofSvBUDhXu',
    signature: '3045022100A887F4C261786803AD033839FB52272E1123A57DFF48C07C06616D2028A4CC0502203F3325B1635864EBBFE44991910D66836F66FC00E14E965AB0F5352AD97816FF',
    master_signature: '1234567890ABCDEF'
  }
}

verifyManifestSignature(manifest): bool

Verify a manifest signature. Various manifest formats are supported. The following examples show the supported manifest formats:

> await verifyManifestSignature("240000007B7121EDA54C85F91219FD259134B6B126AD64AE7204B81DD4052510657E1A5697246AD27321032F7ACF6D67C42C9C898F576F92FE4638EB6C88D0DC7F6710AF00ED6BF50D97D676473045022100BE0B2E6071AED53C19A76BDC6EDE1A351C35343AA7CF917587F93C9D85C5A7B702207135F72654DC3AD70FE8A4DEB128965268A312DFB3E9A7C68BA8E9A8931F4285770F7261626269746B69636B2E636C7562701240C4FF2A6D277D24DEFB1C1EDF67285171EA02DC035FEF6216DEE41019CE41611AD4430AF59938DC505E538CCF669D521AC2A456C3805FE3CA85BB10B2A691B50B")
> true
> await verifyManifestSignature({
  Sequence: 123,
  Signature: '3045022100BE0B2E6071AED53C19A76BDC6EDE1A351C35343AA7CF917587F93C9D85C5A7B702207135F72654DC3AD70FE8A4DEB128965268A312DFB3E9A7C68BA8E9A8931F4285',
  MasterSignature: 'C4FF2A6D277D24DEFB1C1EDF67285171EA02DC035FEF6216DEE41019CE41611AD4430AF59938DC505E538CCF669D521AC2A456C3805FE3CA85BB10B2A691B50B',
  Domain: 'rabbitkick.club',
  PublicKey: 'nHUcNC5ni7XjVYfCMe38Rm3KQaq27jw7wJpcUYdo4miWwpNePRTw',
  SigningPubKey: 'n9Li9iXepgXECvTFq2hGoxqSttJy9rrC1NbZ75NXLZyKFekV5ZU1'
})
> true
> await verifyManifestSignature({
  master_key: "nHBQ3CT3EWYZ4uzbnL3k6TRf9bBPhWRFVcK1F5NjtwCBksMEt5yy",
  master_signature: "0B7C84A7F192A3CC781393876C76863AE401AEE57937A706D7FD0F1BA1C2582C07D37FC714DFA73310923518A188B25E45D9CA1D4D56C34B0CA52639D5992C03",
  seq: 2,
  signature: "3045022100A4622D77AF27AD6E92166D8A4BC2B8A80646757C1F4F1E33F3C4BC9344765D38022062FC193AF1555E7D1D46B6023861ECD1415B319C488DFCB99648D99060A41120",
  signing_key: "n9K7fyu8uvmCoWvW4ZQVCWgW2zrz7sh33Ao7ceNkL7iQGDYtuwTU"
})
> true

Testing

To run the tests:

  1. Install dependencies with yarn install or npm install
  2. Run yarn test or npm test