How to use urbit-key-generation - 10 common examples

To help you get started, we’ve selected a few urbit-key-generation 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 urbit / bridge / src / views / SetKeys.js View on Github external
createUnsignedTxn() {
    const { state, props } = this;

    const validContracts = need.contracts(props.contracts);
    const validPoint = need.point(props.pointCursor);

    // TODO: move this to a lib for validating things
    const hexRegExp = /[0-9A-Fa-f]{64}/g;

    if (hexRegExp.test(state.newNetworkSeed)) {
      // derive network keys
      const pair = kg.deriveNetworkKeys(state.newNetworkSeed);

      const pencr = addHexPrefix(pair.crypt.public);
      const pauth = addHexPrefix(pair.auth.public);

      const txn = azimuth.ecliptic.configureKeys(
        validContracts,
        validPoint,
        pencr,
        pauth,
        1,
        state.discontinuity
      );

      return Just(txn);
    }
github urbit / bridge / src / lib / walletgen.js View on Github external
export const generateWallet = async (point, ticket, boot) => {
  const config = {
    ticket: ticket,
    seedSize: SEED_LENGTH_BYTES,
    ship: point,
    password: '',
    revisions: {},
    boot: boot,
  };

  // This is here to notify anyone who opens console because the thread
  // hangs, blocking UI updates so this cannot be done in the UI
  console.log('Generating Wallet for point address: ', point);

  const wallet = await kg.generateWallet(config);

  return wallet;
};
github urbit / bridge / src / lib / keys.js View on Github external
const deriveNetworkSeedFromMnemonic = async (
  mnemonic,
  passphrase,
  revision
) => {
  //NOTE revision is the point's on-chain revision number. since common uhdw
  //     usage derives the first key at revision/index 0, we need to decrement
  //     the on-chain revision number by one to get the number to derive with.
  return Just(await kg.deriveNetworkSeed(mnemonic, passphrase, revision - 1));
};
github urbit / bridge / src / views / Shards.js View on Github external
async walletFromShards(shard1, shard2, shard3, pointName, passphrase) {
    const s1 = shard1 === '' ? undefined : shard1;
    const s2 = shard2 === '' ? undefined : shard2;
    const s3 = shard3 === '' ? undefined : shard3;

    let ticket = undefined;
    try {
      ticket = kg.combine([s1, s2, s3]);
    } catch (_) {
      // do nothing
    }

    if (ticket !== undefined) {
      const uhdw = await urbitWalletFromTicket(ticket, pointName, passphrase);
      this.props.setUrbitWallet(Just(uhdw));
    }
  }
github urbit / bridge / src / views / Login / Ticket.js View on Github external
async values => {
      const ticket = values.useShards
        ? kg.combine([values.shard1, values.shard2, values.shard3])
        : values.ticket;

      try {
        const _contracts = need.contracts(contracts);
        const point = patp2dec(values.point);

        await timeout(16); // allow ui events to flush
        const urbitWallet = await urbitWalletFromTicket(
          ticket,
          point,
          values.passphrase
        );

        const [isOwner, isTransferProxy] = await Promise.all([
          azimuth.azimuth.isOwner(
            _contracts,
github urbit / bridge / src / views / Login / Shards.js View on Github external
const walletFromShards = async () => {
    const s1 = shard1 === '' ? undefined : shard1;
    const s2 = shard2 === '' ? undefined : shard2;
    const s3 = shard3 === '' ? undefined : shard3;

    let ticket = undefined;
    try {
      ticket = kg.combine([s1, s2, s3]);
    } catch (_) {
      // do nothing
    }

    if (ticket !== undefined) {
      const uhdw = await urbitWalletFromTicket(ticket, pointName, passphrase);
      setUrbitWallet(Just(uhdw));
    }
  };
github urbit / bridge / src / views / GenKeyfile.js View on Github external
checkKeysMatch(networkSeed, pointDetails) {
    const crypub = pointDetails.encryptionKey;
    const sgnpub = pointDetails.authenticationKey;

    const { crypt, auth } = kg.deriveNetworkKeys(networkSeed);

    const keysmatch =
      crypub === addHexPrefix(crypt.public) &&
      sgnpub === addHexPrefix(auth.public);

    return keysmatch;
  }
github urbit / bridge / src / lib / wallet.js View on Github external
export const urbitWalletFromTicket = async (ticket, point, passphrase) => {
  return await kg.generateWallet({
    ticket: ticket,
    ship: point,
    passphrase: passphrase,
  });
};
github urbit / bridge / src / lib / keys.js View on Github external
export const deriveNetworkKeys = seed => kg.deriveNetworkKeys(seed);
github urbit / bridge / src / lib / walletgen.js View on Github external
export const generateOwnershipWallet = (ship, ticket) =>
  kg.generateOwnershipWallet({ ship, ticket });