question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Add chainId to PublicIdentity

See original GitHub issue

A cryptographic keypair should be bound to one specific chain to avoid replay attacks. Also it should be easy to convert a PublicIdentity to an address, which requires the knowledge of the chainId.

  • Add chainId parameter to Wallet.createIdentity
  • Add chainId to PublicIdentity
  • Remove redundant chainId parameter from Wallet.createTransactionSignature
  • Convert MultiChainSigner.keyToAddress into identityToAddress(identity: PublicIdentity): Address
  • Convert TxReadCodec.keyToAddress into identityToAddress(identity: PublicIdentity): Address

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Reactions:1
  • Comments:9 (9 by maintainers)

github_iconTop GitHub Comments

1reaction
ethanfreycommented, Dec 20, 2018

Example interface (please modify, give feedback based on client requirements above, or question those requirements):

(Here I intentionally omit the naming of local identities, we can add that once we find a good agreement how derivations work).

export type AccountId = string & As<"accountId">;
export interface ChainPath {
  readonly chainId: ChainId;
  readonly algo: "secp256k1" | "ed25519";
  /** Examples are the methods from HdPaths */
  readonly path: (n: int) => ReadonlyArray<Slip10RawIndex>;
};
export interface IdentityQuery {
  readonly chain?: ChainId;
  readonly account?: AccountId;
};
export interface PublicIdentity {
  readonly chain: ChainId;
  readonly account: AccountId;
  readonly address: Address;  // chain-specific address
  readonly pubkey: PublicKeyBundle; // Note: contains algorithm
  readonly path: ReadonlyArray<Slip10RawIndex>;
  // TODO: add label
};

export declare class MultiChainProfile {
    static loadFrom(db: LevelUp<AbstractLevelDOWN<string, string>>, password: string): Promise<MultiChainProfile>;

    readonly createdAt: ReadonlyDate;
    readonly locked: ValueAndUpdates<boolean>;
    readonly accounts: ValueAndUpdates<ReadonlyArray<AccountId>>;
    readonly chains: ValueAndUpdates<ReadonlyArray<ChainPath>>;

    constructor(options?: MultiChainOptions);
    storeIn(db: LevelUp<AbstractLevelDOWN<string, string>>, password: string): Promise<void>;
    lock(): void;

    /** This creates a new account and initializes a PublicIdentity for each Chain */
    createAccount(): Promise<AccountId>;
    /** This adds support for a chain, and adds a new PublicIdentity for each existing Account */
    addChain(chain: ChainPath): Promise<void>; 

    getIdentities(query: IdentityQuery): ReadonlyArray<PublicIdentity>;
    // TODO: watchIdentities as well???
    // watchIdentities(query: IdentityQuery): Stream<ReadonlyArray<PublicIdentity>>;

    // here we just use AccountId, as ChainId is inside the UnsignedTransaction, and the profile can use that info to find the proper PublicIdentity
    signTransaction(identity: AccountId, transaction: UnsignedTransaction, codec: TxCodec, nonce: Nonce): Promise<SignedTransaction>;
    appendSignature(identity: AccountId, originalTransaction: SignedTransaction, codec: TxCodec, nonce: Nonce): Promise<SignedTransaction>;

    // TODO: maybe rename... we can guaranteed it is mnemonic in this case.
    printableSecret(): string;
}

(note: updated types for signing a bit)

0reactions
ethanfreycommented, Dec 20, 2018

After some discussion with Simon, I support this issue:

  • All my comments for functionality should go into some IdentityManager that can be implemented in the Wallet application to provide whatever functionality we need.
  • Add chainId to all Identities in UserProfile, which can then easily get a unique address from the signer, as Simon suggested above.
  • Update interface on MultiChainSigner, so one could drop in IdentityManager as an alternative to UserProfile (will make PR now).
Read more comments on GitHub >

github_iconTop Results From Across the Web

How To Specify ChainID - Ethereum Stack Exchange
I am interacting with the Harmony testnet using web3j, but since Harmony has 4 shards i also have to specify the chainID, otherwise...
Read more >
Getting started with the CLI - Ceramic Developers
1. Install the CLIs · 2. Start the Ceramic daemon · 3. Create a Ceramic account · 4. Create a stream · 5....
Read more >
flow - Go Packages
A ChainID is a unique identifier for a specific Flow network instance. ... Identity represents the public identity of one network ...
Read more >
Mix nodes | Nym Docs
Note that your node's public identity key is displayed during startup, ... nyxd keys add -i mix0-famhead # the head of the mix...
Read more >
Factom CLI Commands - Factom Protocol Docs
c CHAINID] \. [-e EXTID1 -e EXTID2 -x HEXEXTID ...] [-CET] ECADDRESS <STDIN>. The addentry subcommands support the -e and -x flags for...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found