We need to be able to refer a contract by a name with the following properties
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]
RegistrySigGen uses function Secp256k1.newKeyPair to generate a new key pair for each contract inserted in the registry.
The contracts in casper use the maxLong nonce 9223372036854775807.
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.
The signature is computed over a tuple containing the above nonce and a bundle+ of the above unforgeable name.
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.
The contract is inserted in the registry by using the system call `rho:registry:insertSigned:secp256k1` like in the code below:
new
MakeMint, rs(`rho:registry:insertSigned:secp256k1`), uriOut
in {
contract MakeMint(...) = { ... } |
rs!(
"d9ba2075d355755060205605f4cdbd5ecd3cce5ed1f39690f34772f7c9aa30ab".hexToBytes(),
(9223372036854775807, bundle+{*MakeMint}),
"36229e3f4530c15f3b7c1d9165369201b70b4673289a003652af14b436b20a275d5909d6dfbbd06e685292d39eadf3af11db6f882dcc78ef0b794e6da0ad6109".hexToBytes(),
*uriOut)
}
Use a single key-pair for signing multiple contracts and