stawi_finance_sdk 0.2.0
stawi_finance_sdk: ^0.2.0 copied to clipboard
Stawi client SDK: canonical FinancialIntent encoding, intent digests, account derivation, policy hashes, manifest verification, exact money arithmetic and device signing. Pure Dart; no Flutter, no transport.
stawi_finance_sdk #
Pure-Dart client SDK for Stawi: canonical FinancialIntent encoding and
digests, account derivation, policy hashes, protocol manifest verification,
exact money arithmetic and device signing. No Flutter and no transport; pair
it with stawi_api for the Connect clients.
Signing a prepared settlement call #
import 'package:stawi_finance_sdk/stawi_finance_sdk.dart';
// Once per device; persist key.privateKey in secure storage.
final key = DeviceKey.generate(); // Random.secure(), rejects 0 and >= n
print(bytesToHex0x(key.address)); // keccak256(X ‖ Y)[12:]
// PrepareRoomCallResponse.digest or PrepareAccountCallResponse.intent_digest:
final signature = signPreparedCall(preparedDigest, key.privateKey);
// 65 bytes r ‖ s ‖ v, v in {27, 28}: DeviceSignature.signature
// (algorithm "secp256k1") for SubmitRoomCall, or SubmitAccountCall.authorization.
accountWrappedHash(account, chainId, hash) is StawiAccount's ERC-1271
wrapping, for checking a prepared digest against the call's typed hash.
Every primitive is checked against vectors produced by the Go
implementation (test/vectors/).