Delegate Key Signing
Delegate Key Signing
All events in the River Protocol are signed by an ECDSA wallet key pair. Users and nodes can both send events using a process referred to as delegate signing that allows for events to be signed by a separate device linked to the primary wallet. Delegate signing therefore opens the protocol to allow events from linked devices the user has custody of. River Stream Nodes validate the signature prior to processing an event that is for example being added to a stream using addEvent
RPC method.
The rules and construction of the delegate key signature are the topic of this page.
Delegate Signature Protocol Rules
The logic dictating how a River Stream Node should process delegate signatures on the critical path of a request are described in protocol.proto
and defined in delegate.go
.
Events sent over RPC to a River Stream Node are sent with a message Envelope
that includes several fields used to validate the sender.
- signature : For the event to be valid, the signature on the
Envelope
must match theEvent
creator_address or be signed by the same address implied byEvent
delegate_sig. - creator_address : This is the wallet address of the creator of the event, which can be a user or a River Stream Node.
- delegate_sig : Optional field that allows events to be signed by a device keypair linked to the user’s primary wallet.
Delegate Signature Validation
Each event on a River Stream Node is parsed and validated as follows.
Unmarshal Bytes
Events are stored as bytes in River Stream Node storage and transmitted as bytes over the wire. All events are unmarshalled first then parsed to run a series of validity checks prior to storing those events.
River Hash
The event hash is first validated using RiverHash
function found in sign.go
.
Check Delegate Signature
Once the hash is confirmed as valid for the event, the hash along with the envelope signature are used to recover the signer public key.
Check Delegate Signature
If the delegate signature is present on the event, the creator address is used in conjunction with the previously retrieved public key and delegate signature to prove that the signature was signed by the creator.
secp256k1
algorithm is used to validate signature and sign. River Stream Nodes use a hardened version of this algorithm found in go-ethereum package. Node Delegate Events
River Stream Nodes are created with an ECDSA wallet used for identity and so can create events destined for streams in the network just like users using their Ethereum wallet as a primary wallet or another linked wallet created using ECDSA.
Nodes create new wallets using go-ethereum
crypto tools in the following function.
Was this page helpful?