Skip to content

Latest commit

 

History

History
128 lines (88 loc) · 3.86 KB

File metadata and controls

128 lines (88 loc) · 3.86 KB

Keypair

Represents two asymmetric cryptography keypairs

  • a signing keypair
  • an encryption keypair

base64url encoded identity string to represent the public sides

can optionally be initialized without the private halves of the pairs

Kind: global class

new Keypair(opt)

keypair constructor (you probably want one of the static functions above)

Param Type Description
opt object
opt.pubkeys string the keypair identity string
[opt.signPriv] Buffer private signature key
[opt.encPriv] Buffer private encryption key

keypair.getId() ⇒ string

get the keypair identifier string

Kind: instance method of Keypair

keypair.sign(data)

sign some arbitrary data with the signing private key

Kind: instance method of Keypair

Param Type Description
data Buffer the data to sign

keypair.verify(signature, data)

verify data that was signed with our private signing key

Kind: instance method of Keypair

Param Type
signature Buffer
data Buffer

keypair.encrypt(recipientIds, data) ⇒ Buffer

encrypt arbitrary data to be readale by potentially multiple recipients

Kind: instance method of Keypair

Param Type Description
recipientIds array.<string> multiple recipient identifier strings
data Buffer the data to encrypt

keypair.decrypt(sourceId, cipher) ⇒ Buffer

attempt to decrypt the cipher buffer (assuming it was targeting us)

Kind: instance method of Keypair
Returns: Buffer - - the decrypted data

Param Type Description
sourceId string identifier string of who encrypted this data
cipher Buffer the encrypted data

keypair.getBundle(passphrase, hint)

generate an encrypted persistence bundle

Kind: instance method of Keypair

Param Type Description
passphrase string the encryption passphrase
hint string additional info / description for the bundle

Keypair.newFromSeed(seed)

derive the pairs from a 32 byte seed buffer

Kind: static method of Keypair

Param Type Description
seed Buffer the seed buffer

Keypair.fromBundle(bundle, passphrase)

initialize the pairs from an encrypted persistence bundle

Kind: static method of Keypair

Param Type Description
bundle object persistence info
passphrase string decryption passphrase