How to use the ssb-keys.hash function in ssb-keys

To help you get started, we’ve selected a few ssb-keys examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github ssbc / ssb-peer-invites / test / invalid.js View on Github external
type: 'peer-invite/accept',
    receipt: '%'+ssbKeys.hash(JSON.stringify(invite_msg, null, 2)),
    id: bob.id,
    key: u.hash(u.hash(seed)) //what the reveal key should be.
  })

  var accept_msg =
    v.create(null, bob, caps.sign, accept, new Date('2018-03-26T06:14:18.377Z'))

  throws(t, function () {
    i.verifyAccept(accept_msg, invite_msg, caps)
  }, 'peer-invites:decrypt-accept-reveal-failed')

  var accept2 = ssbKeys.signObj(ssbKeys.generate(null, seed), caps.peerInvite, {
    type: 'peer-invite/accept',
    receipt: '%'+ssbKeys.hash(JSON.stringify(invite_msg, null, 2)),
    id: bob.id,
    key: u.hash('not the key') //what the reveal key should be.
  })

  throws(t, function () {
    i.verifyAccept(accept_msg, invite_msg, caps)
  }, 'peer-invites:decrypt-accept-reveal-failed')

  t.end()
})
github ssbc / ssb-peer-invites / test / accept3.js View on Github external
function toId(msg) {
  return '%'+ssbKeys.hash(JSON.stringify(msg, null, 2))
}
github ssbc / ssb-peer-invites / test / accept2.js View on Github external
function toId(msg) {
  return '%'+ssbKeys.hash(JSON.stringify(msg, null, 2))
}
github ProjectEntropy / scuttle-vue / modules / sbot.js View on Github external
}, function (err) {
    if(err && !onHash) throw err
    var b = buffers.length > 1 ? Buffer.concat(buffers) : buffers[0]
    var h = '&'+ssbKeys.hash(b)
    onHash && onHash(err, h)
  })
}
github ssb-junkyard / ssb-feed / validator.js View on Github external
function validate(id) {
    var feed = latest[id]
    if(!feed.queue.length) return
    if(!feed.ready) return

    while(feed.queue.length) {
      var op = feed.queue.shift()


      if('function' == typeof op.create) {
        op.value = op.create(feed.key, feed.value)
        op.key = '%'+hash(encode(op.value))
      }

      var err =
        util.isInvalidShape(op.value) ||
        util.isInvalid(id, op.value, feed, sign_cap)

      if(err)
        op.cb(err)
      else {
        feed.key = op.key
        feed.value = op.value
        feed.ts = Date.now()
        write(op)
      }
    }
  }
github ssbc / ssb-peer-invites / valid.js View on Github external
function toMsgId(msg) {
  return '%'+ssbKeys.hash(JSON.stringify(msg, null, 2))
}
github mmckegg / patchwork-next / api / index.js View on Github external
}, function (err) {
    if(err && !onHash) throw err
    var b = buffers.length > 1 ? Buffer.concat(buffers) : buffers[0]
    var h = '&'+ssbKeys.hash(b)
    onHash && onHash(err, h)
  })
}
github ssb-junkyard / ssb-feed / validator.js View on Github external
function add (msg, cb) {
    var err = util.isInvalidShape(msg)
    if(err) return cb(err)

    queue(msg.author, {
        key: '%'+hash(encode(msg)),
        value: msg, cb: cb,
        create: null
      })
  }