How to use the borc.Tagged function in borc

To help you get started, we’ve selected a few borc 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 vacuumlabs / cardano-crypto.js / index.js View on Github external
} else {
    addressPayload = Buffer.from([])
    addressAttributes = new Map()
  }

  const addressRoot = getAddressHash([
    0,
    [0, xpub],
    addressPayload.length > 0 ? new Map([[1, cbor.encode(addressPayload)]]) : new Map(),
  ])
  const addressType = 0 // Public key address
  const addressData = [addressRoot, addressAttributes, addressType]
  const addressDataEncoded = cbor.encode(addressData)

  return base58.encode(
    cbor.encode([new cbor.Tagged(24, addressDataEncoded), crc32(addressDataEncoded)])
  )
}
github ipld / js-ipld-dag-cbor / src / util.js View on Github external
function tagCID (cid) {
  if (typeof cid === 'string') {
    cid = new CID(cid).buffer
  } else if (CID.isCID(cid)) {
    cid = cid.buffer
  }

  return new cbor.Tagged(CID_CBOR_TAG, Buffer.concat([
    Buffer.from('00', 'hex'), // thanks jdag
    cid
  ]))
}
github zbo14 / constellate / lib / dag-cbor.js View on Github external
const tagged = transform(elem, val => {
        if (!isObject(val)) {
            return val
        }
        if (seen.some(obj => orderStringify(obj) === orderStringify(val))) {
            return tasks.error('the object passed has circular references')
        }
        seen.push(val)
        if (!(cid = val['/'])) {
            return val
        }
        if (isString(cid)) {
            cid = new CID(cid.split('/')[0]).buffer
        }
        return new cbor.Tagged(CID_CBOR_TAG, Buffer.concat([
            Buffer.from('00', 'hex'), cid
        ]))
    })
    try {
github zbo14 / constellate / src / dag-cbor.js View on Github external
const tagged = transform(obj, val => {
    if (val.constructor !== Object) {
      return val
    }
    if (seen.some(obj => orderStringify(obj) === orderStringify(val))) {
      stop = true
      return cb(new Error('the object passed has circular references'))
    }
    seen.push(val)
    if (!(cid = val['/'])) {
      return val
    }
    if (typeof cid === 'string') {
      cid = new CID(cid.split('/')[0]).buffer
    }
    return new cbor.Tagged(CID_CBOR_TAG, Buffer.concat([
      Buffer.from('00', 'hex'), cid
    ]))
  })
  if (!stop) {
github vacuumlabs / adalite / app / frontend / wallet / transaction.ts View on Github external
function encodeCBOR(encoder) {
    return encoder.pushAny([
      type,
      new Tagged(24, encode([Buffer.from(txHash, 'hex'), outputIndex]), null),
    ])
  }
github vacuumlabs / adalite / app / frontend / wallet / transaction.ts View on Github external
function encodeCBOR(encoder) {
    return encoder.pushAny([type, new Tagged(24, encode([extendedPublicKey, signature]), null)])
  }
github vacuumlabs / adalite / app / frontend / wallet / transaction.ts View on Github external
function encodeCBOR(encoder) {
    return encoder.pushAny([
      type,
      new Tagged(24, encode([Buffer.from(txHash, 'hex'), outputIndex]), null),
    ])
  }

borc

Encode and parse data in the Concise Binary Object Representation (CBOR) data format (RFC7049).

MIT
Latest version published 3 years ago

Package Health Score

54 / 100
Full package analysis