Skip to content
On this page

Cryptography

Some constructions are only available in tests, not in smart contracts.

sp.test_account(seed) → test_account

Creating a deterministic key-pair from a seed string:

python
# seed is `Alice`
alice = sp.test_account("Alice")

It produces an object with the following properties:

PropertyTypeDescription
alice.addresssp.addressGives the public-key-hash
alice.public_key_hashsp.key_hashGives the public-key-hash
alice.public_keysp.keyGives the public-key
alice.secret_keysp.stringGives the secret-key
sp.make_signature(secret_key, message, message_format = 'Raw') → sp.signature

Forges a signature compatible with sp.check_signature(...).

message_format field accepts two values:

  • Hex in which case the message will be interpreted as an hexadecimal string;
  • Raw (the default) in which case the message is a sp.bytes value (usually the result of an sp.pack call).

INFO

sp.test_account methods and sp.make_signature are not available for compilation to Michelson (a smart contract cannot manipulate secret keys).