-
Notifications
You must be signed in to change notification settings - Fork 114
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Shumo Chu
committed
Feb 5, 2020
1 parent
8c90fa5
commit 7e7fb86
Showing
2 changed files
with
26 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
.. _crypto: | ||
|
||
Cryptographic Primitives | ||
======================== | ||
|
||
Algorand Smart Contracts support 4 cryptographic primitives, including 3 cryptographic | ||
hash functions and 1 digital signature verification. Each of these cryptographic | ||
primitives is associated with a cost, which is a number indicating its relative performance | ||
overhead comparing with simple teal operations such as addition and substraction. | ||
All TEAL opcodes except crypto primitives have cost `1`. | ||
Below is how you express cryptographic primitives in PyTeal: | ||
|
||
|
||
=============================== ========= ================================================================================ | ||
Operator Cost Description | ||
=============================== ========= ================================================================================ | ||
:code:`Sha256(e)` `7` `SHA-256` hash function, produces 32 bytes | ||
:code:`Keccak256(e)` `26` `Keccak-256` hash funciton, produces 32 bytes | ||
:code:`Sha512_256(e)` `9` `SHA512-256` hash function, produces 32 bytes | ||
:code:`Ed25519verify(d, s, p)` `1900` `1` if :code:`s` is the signature of :code:`d` signed by :code:`p` (PK), else `0` | ||
=============================== ========= ================================================================================ | ||
|
||
These cryptographic primitives cover the most used ones in blockchains and cryptocurrencies. For example, Bitcoin uses `SHA-256` for creating Bitcoin addresses; | ||
Alogrand uses `ed25519` signature scheme for authorization and uses `SHA512-256` hash function for | ||
creating contract account addresses from TEAL bytecode. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters