Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/CI.yml
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ jobs:
platform:
- runner: macos-latest
target: x86_64
- runner: macos-13
- runner: macos-14
target: aarch64
python-version: ["3.10", "3.11", "3.12", "3.13"]
steps:
Expand Down
12 changes: 6 additions & 6 deletions docs/src/pages/guides/keys-and-signatures.md
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@ Signing data is a fundamental cryptographic operation that provides both authent

In this section, we'll explore two primary ways of signing data: with hashing (using the `sign()` method) and without hashing (using the `sign_raw()` method).

Additionally, we will touch upon the optional incorporation of a `signature_id` to further enhance the identification of the signed data.
Additionally, we will touch upon the optional incorporation of a `signature_context` to further enhance the identification of the signed data.

### Data with Hashing

Expand All @@ -230,9 +230,9 @@ When signing data using the `sign()` method, the data is first hashed before bei
```python
data = b"Hello, World 42!"

signature_id = await transport.get_signature_id() # Optional
signature_context = await transport.get_signature_context() # Optional

signature = keypair.sign(data, signature_id)
signature = keypair.sign(data, signature_context)

print(signature)
```
Expand All @@ -244,7 +244,7 @@ Signature('b2bd3045b3ec3872bcccc96f58b71fe0fd60cba104249cc5e72c1a2ebad35cbbf1d82
```

:::tip
The `signature_id` is an optional identifier for a signature, sourced directly from the transport layer using the `get_signature_id()` method. If this is your first time encountering `signature_id` or you're unfamiliar with our transport layer, it's recommended to [read our guide on working with the transport](./working-with-transport.md) to get started.
The `signature_context` is an optional context for a signature, sourced directly from the transport layer using the `get_signature_context()` method. If this is your first time encountering `signature_context` or you're unfamiliar with our transport layer, it's recommended to [read our guide on working with the transport](./working-with-transport.md) to get started.
:::

### Raw Data
Expand All @@ -271,7 +271,7 @@ To verify a signature, you need to use the correct input depending on the signin

If it was signed with `sign_raw()`, you should either use the hash of the original data (if you want to verify the signature against hashed data) or the original data itself (if you want to verify the signature against raw data).

When a `signature_id` was used during signing, the same `signature_id` should be used for verification.
When a `signature_context` was used during signing, the same `signature_context` should be used for verification.

### Hashed Signature

Expand All @@ -282,7 +282,7 @@ import hashlib

data = hashlib.sha256(b"Hello, World 42!").digest()

is_valid = public_key.check_signature(data, signature, signature_id)
is_valid = public_key.check_signature(data, signature, signature_context)

print(is_valid) # True
```
Expand Down
8 changes: 4 additions & 4 deletions docs/src/pages/guides/working-with-messages.md
Original file line number Diff line number Diff line change
Expand Up @@ -306,11 +306,11 @@ print(expire_at) # 1695429486

### Signing an Unsigned External Message

The `sign` method allows you to sign an unsigned external message. This requires a `KeyPair` and an optional `signature_id`.
The `sign` method allows you to sign an unsigned external message. This requires a `KeyPair` and an optional `signature_context`.

```python
# Sign the unsigned message
signed_message = unsigned_message.sign(keypair, signature_id)
signed_message = unsigned_message.sign(keypair, signature_context)

print(signed_message)
```
Expand Down Expand Up @@ -383,11 +383,11 @@ print(without_signature_message)

### Signing the External Message Body

The `sign` method of the `UnsignedBody` class allows you to sign the body of an external message. This requires a `KeyPair` and an optional `signature_id`.
The `sign` method of the `UnsignedBody` class allows you to sign the body of an external message. This requires a `KeyPair` and an optional `signature_context`.

```python
# Sign the body of the unsigned message
signed_body = unsigned_body.sign(keypair, signature_id)
signed_body = unsigned_body.sign(keypair, signature_context)

print(signed_body)
```
Expand Down
8 changes: 4 additions & 4 deletions docs/src/pages/guides/working-with-transport.md
Original file line number Diff line number Diff line change
Expand Up @@ -130,14 +130,14 @@ print(raw_param)
<Cell repr_hash='e6025a4b06943baa939e0497bf474bf8b946938d5a4d70bd2fae2b7d481b3cb9', bits=256, refs=0>
```

## Fetching Signature ID
## Fetching Signature Context

You can fetch the signature ID for the selected network using the `get_signature_id` method. This method does not take any parameters.
You can fetch the signature context for the selected network using the `get_signature_context` method. This method does not take any parameters.

```python
signature_id = await transport.get_signature_id()
signature_context = await transport.get_signature_context()

print(signature_id)
print(signature_context)
```

##### Result
Expand Down
1 change: 1 addition & 0 deletions python/nekoton/contracts/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@
from .giver_v2 import GiverV2 as GiverV2
from .highload_wallet_v2 import HighloadWalletV2 as HighloadWalletV2
from .walletv3 import WalletV3 as WalletV3
from .walletv5 import WalletV5 as WalletV5
9 changes: 4 additions & 5 deletions python/nekoton/contracts/ever_wallet.py
Original file line number Diff line number Diff line change
Expand Up @@ -144,8 +144,7 @@ async def send(
bounce: bool = False,
) -> _nt.Transaction:
state_init = await self.__get_state_init()

signature_id = await self._transport.get_signature_id()
context = await self._transport.get_signature_context()

external_message = _send_transaction.encode_external_message(
self._address,
Expand All @@ -158,7 +157,7 @@ async def send(
},
public_key=self._keypair.public_key,
state_init=state_init,
).sign(self._keypair, signature_id)
).sign(self._keypair, context)

tx = await self._transport.send_external_message(external_message)
if tx is None:
Expand All @@ -173,7 +172,7 @@ async def send_raw(
raise RuntimeError("Too many messages at once")

state_init = await self.__get_state_init()
signature_id = await self._transport.get_signature_id()
context = await self._transport.get_signature_context()

abi = _send_transaction_raw[len(messages)]
input = dict()
Expand All @@ -186,7 +185,7 @@ async def send_raw(
input,
public_key=self._keypair.public_key,
state_init=state_init,
).sign(self._keypair, signature_id)
).sign(self._keypair, context)

tx = await self._transport.send_external_message(external_message)
if tx is None:
Expand Down
8 changes: 4 additions & 4 deletions python/nekoton/contracts/giver_v2.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,13 +95,13 @@ async def deploy(
raise RuntimeError("Message expired")
await transport.trace_transaction(tx).wait()

signature_id = await transport.get_signature_id()
context = await transport.get_signature_context()
external_message = _giver_v2_constructor.encode_external_message(
address,
input={},
public_key=keypair.public_key,
state_init=state_init,
).sign(keypair, signature_id)
).sign(keypair, context)
tx = await transport.send_external_message(external_message)
if tx is None:
raise RuntimeError("Message expired")
Expand All @@ -121,7 +121,7 @@ def address(self) -> _nt.Address:
return self._address

async def give(self, target: _nt.Address, amount: _nt.Tokens):
signature_id = await self._transport.get_signature_id()
context = await self._transport.get_signature_context()

# Prepare external message
message = _giver_v2_send_grams.encode_external_message(
Expand All @@ -132,7 +132,7 @@ async def give(self, target: _nt.Address, amount: _nt.Tokens):
"bounce": False,
},
public_key=self._keypair.public_key,
).sign(self._keypair, signature_id)
).sign(self._keypair, context)

# Send external message
tx = await self._transport.send_external_message(message)
Expand Down
4 changes: 2 additions & 2 deletions python/nekoton/contracts/highload_wallet_v2.py
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ async def send_raw(
raise RuntimeError("Too many messages at once")

state_init = await self.__get_state_init()
signature_id = await self._transport.get_signature_id()
context = await self._transport.get_signature_context()

expire_at = self._transport.clock.now_sec + _default_ttl if ttl is None else ttl

Expand All @@ -141,7 +141,7 @@ async def send_raw(
payload_builder.store_slice(messages_dict_cell.as_slice())

hash_to_sign = payload_builder.build().repr_hash
signature = self._keypair.sign_raw(hash_to_sign, signature_id)
signature = self._keypair.sign_raw(hash_to_sign, context)

body_builder = _nt.CellBuilder()
body_builder.store_signature(signature)
Expand Down
4 changes: 2 additions & 2 deletions python/nekoton/contracts/walletv3.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ async def send_raw(
raise RuntimeError("Too many messages at once")

seqno, state_init = await self.__get_seqno_and_state_init()
signature_id = await self._transport.get_signature_id()
context = await self._transport.get_signature_context()

expire_at = self._transport.clock.now_sec + _default_ttl if ttl is None else ttl

Expand All @@ -122,7 +122,7 @@ async def send_raw(
payload_builder.store_reference(message.build_cell())

hash_to_sign = payload_builder.build().repr_hash
signature = self._keypair.sign_raw(hash_to_sign, signature_id)
signature = self._keypair.sign_raw(hash_to_sign, context)

body_builder = _nt.CellBuilder()
body_builder.store_signature(signature)
Expand Down
Loading
Loading