Skip to content

Commit 72cfbb2

Browse files
committed
added crypto examples to the docs
1 parent e28d879 commit 72cfbb2

File tree

2 files changed

+16
-0
lines changed

2 files changed

+16
-0
lines changed

README.md

+1
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,7 @@ def get_top_level_signer():
122122
- [Context](/docs/concepts/context.md)
123123
- [Functions](/docs/concepts/functions.md)
124124
- [Hashing](/docs/concepts/hashing.md)
125+
- [Crypto](/docs/concepts/crypto.md)
125126
- [Imports](/docs/concepts/imports.md)
126127
- [Model](/docs/concepts/model.md)
127128
- [Randoms](/docs/concepts/randoms.md)

docs/concepts/crypto.md

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
## Crypto Standard Library
2+
3+
In this example, the verify_signature function is an exported function in a Xian smart contract. It takes a verification key (vk), a message (msg), and a signature (signature). It uses the verify function from the crypto module to check if the signature is valid for the given message and verification key. The result (True or False) is then returned. This can be used to ensure data integrity and authenticity in transactions within the smart contract environment.
4+
5+
This module uses the `PyNaCl` library under the hood, employing the `Ed25519` signature scheme.
6+
7+
```python
8+
@export
9+
def verify_signature(vk: str, msg: str, signature: str):
10+
# Use the verify function to check if the signature is valid for the given message and verification key
11+
is_valid = crypto.verify(vk, msg, signature)
12+
13+
# Return the result of the verification
14+
return is_valid
15+
```

0 commit comments

Comments
 (0)