You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Branch: newPubKeyEncode
Since we are in the process of changing the changing the public key encoding, those changes affect other aspects of the system.
One aspect of the system that needs to be changed is the way that we encode contracts.
Previously, we encoded contracts with the assumption that the encoded public key is of length 171. With the new system moving forward, the length of the public key is not longer constant.
So the encoding of contracts is now:
First two bytes contains the version, an unsigned 16 bit integer, encoded little endian style.
The next bytes will be the encoded sender public key. The encoding of the public key contains a byte prefix that gives information about the length of the encoding. If the public key is null (in the case of mining contracts), then the third byte will be 0.
The byte after the encoded sender public key is the length of the signature. If the signature is nil (the contract is unsigned), then the signature length is 0. Following this byte is the signature (if it exists).
Following the signature length and signature, is the recipient public key hash, which is of size 32 bytes.
After the recipient public key hash, is the value, an unsigned 64 bit integer, little endian encoded.
After the value, is the state nonce which is also an unsigned 64 bit integer, little endian encoded.
The functions func (c *Contract) Serialize() ([]byte, error) and func (c *Contract) Deserialize(b []byte) errorin contracts.go.
The old implementation still exists, as a reference. Feel free to replace as much as you need. The unit tests have been refactored.
The text was updated successfully, but these errors were encountered:
Branch:
newPubKeyEncode
Since we are in the process of changing the changing the public key encoding, those changes affect other aspects of the system.
One aspect of the system that needs to be changed is the way that we encode contracts.
Previously, we encoded contracts with the assumption that the encoded public key is of length 171. With the new system moving forward, the length of the public key is not longer constant.
So the encoding of contracts is now:
version
, an unsigned 16 bit integer, encoded little endian style.encoded sender public key
. The encoding of the public key contains a byte prefix that gives information about the length of the encoding. If the public key is null (in the case of mining contracts), then the third byte will be 0.value
, an unsigned 64 bit integer, little endian encoded.state nonce
which is also an unsigned 64 bit integer, little endian encoded.The functions
func (c *Contract) Serialize() ([]byte, error)
andfunc (c *Contract) Deserialize(b []byte) error
in contracts.go.The old implementation still exists, as a reference. Feel free to replace as much as you need. The unit tests have been refactored.
The text was updated successfully, but these errors were encountered: