Inserting contracts in the registry


We need to be able to refer a contract by a name with the following properties

  1. persistent - can be used over an over again
  2. forgeable - can be transmitted off-chain
  3. secure - the user wants a cryptographic guarantee that the name refers to the actual contract deployed

Creating the signature

RegistrySigGen tool

It can be found in coop.rchain.casper.util.rholang. Produces the necessary tools to insert a contract in the registry.

$ sbt runMain coop.rchain.casper.util.rholang.RegistrySigGen contractName [timestamp] [privateKey] [unforgeableName]


Generate a Secp256k1 key pair

RegistrySigGen uses function Secp256k1.newKeyPair to generate a new key pair for each contract inserted in the registry.

Produce a nonce

The contracts in casper use the maxLong nonce 9223372036854775807.

Generate an unforgeable name

RegistrySigGen creates a GPrivate instance using the public key and the timestamp as a seed. This guarantees that the resulting unforgeable name will be the same as the first one produced by ```new SomeName in ...```.

Please note that all the Rholang contracts in Casper project are using the registered name as the first one in the top level new because this is the only name we can predict reliably using this method.

Create the signature

The signature is computed over a tuple containing the above nonce and a bundle+ of the above unforgeable name.

Derive an URI from the public key

An id is derived from the public key using a custom hashing algorithm found in Registry.buildURI in Registry.scala

The convention is to prepend "rho:id:" to the derived id.

Inserting the signed contract

The contract is inserted in the registry by using the system call `rho:registry:insertSigned:secp256k1` like in the code below:

MakeMint, rs(`rho:registry:insertSigned:secp256k1`), uriOut
in {
contract MakeMint(...) = { ... } |
(9223372036854775807, bundle+{*MakeMint}),

Change proposal

Use a single key-pair for signing multiple contracts and