Skip to content
This repository was archived by the owner on Jul 31, 2025. It is now read-only.

Commit 1db5753

Browse files
authored
docs: update raw ECDSA and EIP-191 sig mentions (#14)
1 parent 7191a55 commit 1db5753

3 files changed

Lines changed: 19 additions & 24 deletions

File tree

docs/erc-7824.md

Lines changed: 15 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -49,12 +49,6 @@ The Nitrolite protocol defines the following core data structures:
4949
#### Basic Types
5050

5151
```solidity
52-
struct Signature {
53-
uint8 v;
54-
bytes32 r;
55-
bytes32 s;
56-
}
57-
5852
struct Amount {
5953
address token; // ERC-20 token address (address(0) for native tokens)
6054
uint256 amount; // Token amount
@@ -86,7 +80,7 @@ struct State {
8680
uint256 version; // State version incremental number to compare most recent
8781
bytes data; // Application data encoded, decoded by the adjudicator
8882
Allocation[] allocations; // Asset allocation and destination for each participant
89-
Signature[] sigs; // stateHash signatures from participants
83+
bytes[] sigs; // stateHash signatures from participants
9084
}
9185
9286
enum StateIntent {
@@ -132,14 +126,15 @@ For signature verification, the state hash is computed as:
132126
bytes32 stateHash = keccak256(
133127
abi.encode(
134128
channelId,
135-
state.data,
129+
state.intent,
136130
state.version,
131+
state.data,
137132
state.allocations
138133
)
139134
);
140135
```
141136

142-
Note: The stateHash is bare signed without EIP-191 since the protocol is intended to be chain-agnostic.
137+
Note: The smart contract supports all popular signature formats, specifically: raw ECDSA, EIP-191, EIP-712, EIP-1271, and EIP-6492.
143138

144139
### Interfaces
145140

@@ -218,7 +213,7 @@ interface IChannel {
218213
* @param sig Signature of the participant on the funding state
219214
* @return channelId Unique identifier for the joined channel
220215
*/
221-
function join(bytes32 channelId, uint256 index, Signature calldata sig)
216+
function join(bytes32 channelId, uint256 index, bytes calldata sig)
222217
external returns (bytes32);
223218
224219
/**
@@ -253,11 +248,13 @@ interface IChannel {
253248
* @param channelId Unique identifier for the channel
254249
* @param candidate The state being submitted as the latest valid state
255250
* @param proofs Additional states required by the adjudicator
251+
* @param challengerSig Signature of the challenger on the candidate state. Must be signed by one of the participants
256252
*/
257253
function challenge(
258254
bytes32 channelId,
259255
State calldata candidate,
260-
State[] calldata proofs
256+
State[] calldata proofs,
257+
bytes calldata challengerSig
261258
) external;
262259
263260
/**
@@ -284,25 +281,27 @@ interface IDeposit {
284281
/**
285282
* @notice Deposits tokens into the contract
286283
* @dev For native tokens, the value should be sent with the transaction
284+
* @param wallet Address of the account whose ledger is changed
287285
* @param token Token address (use address(0) for native tokens)
288286
* @param amount Amount of tokens to deposit
289287
*/
290-
function deposit(address token, uint256 amount) external payable;
288+
function deposit(address wallet, address token, uint256 amount) external payable;
291289
292290
/**
293291
* @notice Withdraws tokens from the contract
294292
* @dev Can only withdraw available (not locked in channels) funds
293+
* @param wallet Address of the account whose ledger is changed
295294
* @param token Token address (use address(0) for native tokens)
296295
* @param amount Amount of tokens to withdraw
297296
*/
298-
function withdraw(address token, uint256 amount) external;
297+
function withdraw(address wallet, address token, uint256 amount) external;
299298
}
300299
```
301300

302301
### Channel Lifecycle
303302

304-
1. **Creation**: Creator constructs channel config and signs initial state with `StateIntent.INITIALIZE`
305-
2. **Joining**: Participants verify the channel and sign the same funding state
303+
1. **Creation**: Creator constructs channel config and signs initial state with `StateIntent.INITIALIZE`. Second participant are able to join a channel immediately by providing a signature over initial state, and funds will be deducted from their account, if available.
304+
2. **Joining**: Participants verify the channel and sign the same funding state. This step can be omitted by providing a signature over the initial state when creating the channel. Note, however, that this means that funds will be locked from the participant's balance, while `join(...)` allows to fund the channel from external account.
306305
3. **Active**: Once fully funded, the channel transitions to active state for off-chain operation
307306
4. **Off-chain Updates**: Participants exchange and sign state updates according to application logic
308307
5. **Resolution**:
@@ -456,7 +455,7 @@ No backward compatibility issues found. This ERC is designed to coexist with exi
456455

457456
### On-Chain Security
458457

459-
- **Signature Verification**: All state transitions require valid signatures from participants. The protocol uses bare signatures (without EIP-191) for chain agnosticism.
458+
- **Signature Verification**: All state transitions require valid signatures from participants. The protocol supports signatures of all popular formats, including EIP-191 and EIP-712.
460459
- **Challenge Period**: The configurable challenge duration provides time for honest participants to respond to invalid states.
461460
- **Adjudicator Validation**: Custom adjudicators must be carefully audited as they control state transition rules.
462461
- **Reentrancy Protection**: Implementation should follow checks-effects-interactions pattern, especially in fund distribution.

docs/nitrolite_client/types.md

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -30,14 +30,10 @@ A hash of a channel state, represented as a hexadecimal string.
3030
### Signature
3131

3232
```typescript
33-
interface Signature {
34-
v: number; // Recovery value
35-
r: Hex; // First 32 bytes of the signature
36-
s: Hex; // Second 32 bytes of the signature
37-
}
33+
type Signature = Hex;
3834
```
3935

40-
Represents a cryptographic signature used for signing state channel states.
36+
Represents a cryptographic signature used for signing state channel states as a hexadecimal string.
4137

4238
### Allocation
4339

@@ -85,7 +81,7 @@ interface State {
8581
version: bigint; // Version number, incremented for each update
8682
data: Hex; // Application data encoded as hex
8783
allocations: [Allocation, Allocation]; // Asset allocation for each participant
88-
sigs: Signature[]; // State hash signatures
84+
sigs: Signature[]; // State hash signatures
8985
}
9086
```
9187

docs/quick_start/connect_to_the_clearnode.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -554,7 +554,7 @@ const messageSigner = async (payload: RequestData | ResponsePayload): Promise<He
554554
```
555555

556556
## Getting Channel Information
557-
Так
557+
558558
After authenticating with a ClearNode, you can request information about your channels. This is useful to verify your connection is working correctly and to retrieve channel data.
559559

560560
```javascript

0 commit comments

Comments
 (0)