View Source Signet.Signer (Signet v1.3.8)
Summary
Functions
Gets the address for this signer.
Gets the chain id for this signer.
Signet.Signer is a GenServer which can sign messages. This module takes an
mfa (mod, func, args triple) which defines how to actually sign messages.
For instance, Signet.Signer.Curvy
will sign with a public key, or
Signet.Signer.CloudKMS
will sign using a GCP Cloud KMS key. In either
case, the caller should start the GenServer, and then call:
Signet.Signer.sign(MySigner, "message")
. This should return back a
properly signed message.
Handles signing a message. Finds and memoizes address on first call. Address is required for finding recovery bit.
Initializes a new Signet.Signer.
Signs a message using this signing key.
Directly sign a message, not using a signer process.
Starts a new Signet.Signer process.
Functions
Gets the address for this signer.
Examples
iex> signer_proc = Signet.Test.Signer.start_signer()
iex> Signet.Signer.address(signer_proc) |> Signet.Hex.to_address()
"0x63Cc7c25e0cdb121aBb0fE477a6b9901889F99A7"
Gets the chain id for this signer.
Examples
iex> signer_proc = Signet.Test.Signer.start_signer()
iex> Signet.Signer.chain_id(signer_proc)
5
Signet.Signer is a GenServer which can sign messages. This module takes an
mfa (mod, func, args triple) which defines how to actually sign messages.
For instance, Signet.Signer.Curvy
will sign with a public key, or
Signet.Signer.CloudKMS
will sign using a GCP Cloud KMS key. In either
case, the caller should start the GenServer, and then call:
Signet.Signer.sign(MySigner, "message")
. This should return back a
properly signed message.
Note: we also enforce that a given signer process knows its public key, such that we can verify signatures recovery bits. That is, since CloudKMS and other signing tools don't return a recovery bit, necessary for Ethereum, we test all 4 possible bits to make sure a signature recovers to the correct signer address, but we need to know what that address should be to accomplish this task.
Additionally, chain_id is used to return EIP-155 compliant signatures.
Handles signing a message. Finds and memoizes address on first call. Address is required for finding recovery bit.
Initializes a new Signet.Signer.
Signs a message using this signing key.
Examples
iex> signer_proc = Signet.Test.Signer.start_signer()
iex> {:ok, sig} = Signet.Signer.sign("test", signer_proc)
iex> Signet.Recover.recover_eth("test", sig)
...> |> Signet.Hex.to_address()
"0x63Cc7c25e0cdb121aBb0fE477a6b9901889F99A7"
iex> signer_proc = Signet.Test.Signer.start_signer()
iex> {:ok, <<_r::256, _s::256, v::binary>>} = Signet.Signer.sign("test", signer_proc, chain_id: 0x05f5e0ff)
iex> :binary.decode_unsigned(v)
0x05f5e0ff * 2 + 35 + 1
Directly sign a message, not using a signer process.
This is mostly used internally, but can be used safely externally as well.
Starts a new Signet.Signer process.