cpp-sdk README

The project's README from github.com/QuipNetwork/cpp-sdk. As one markdown file: README.md.

Quip C++ SDK

A C++ SDK for interacting with Quip smart contracts on Ethereum networks.

Features

Building

  1. Clone the repository:
git clone https://github.com/QuipNetwork/quip-cpp-sdk.git
cd quip-cpp-sdk
  1. Run the build script:
./build.sh

This will build both the CLI tool and run the test suite.

Usage

CLI Tool

The CLI tool supports both local development and custom network configurations.

Getting Help

# Show comprehensive help and usage information
./build/quip-cli --help

Local Development (Default)

For local development with Hardhat:

./build.sh

Running the CLI

Basic usage:

./build/quip-cli <command> [args]

Commands:

To generate post-quantum keypairs and signatures, please use the hashsigs-cpp library.

End-to-End (E2E) Testing

To run E2E tests against a real blockchain (local devnet, testnet, or mainnet), follow these steps:

  1. Deploy Contracts on a Local Devnet or Testnet

    Use the existing ethereum-sdk project to deploy the QuipFactory and QuipWallet contracts on localhost or use a sepolia contract on eg mainnet or base. For example, from the ethereum-sdk directory:

    cd ../ethereum-sdk
    npx hardhat node & INITIAL_OWNER=$PUBLIC_ADDRESS_YOU_CONTROL npx hardhat run scripts/deploy.ts --network hardhat
    

    This will deploy the contracts and output their addresses, but your local addresses will not match the default addresses and the transaction will unwind.

    Get your local Deployer, WOTSPlus, and QuipFactory addresses and write the deployer address to your ethereum-sdk .env file, then write all three contract addresses to ethereum-sdk/src/addresses.json and run the command again.

    You can check that your contracts are deployed by running npx hardhat console and using the following command with "Deployer" | "WOTSPlus" | "QuipFactory" as the contractName and the associated contract address as contractAddress

    await ethers.getContractAt(`${contractName}`, `${contractAddress}`);
    
  2. Run the E2E Test Script

    Use the provided bash script to run the CLI against the deployed contracts:

# Show E2E test script help
./e2e_test.sh --help

# Run all tests against local Hardhat network
./e2e_test.sh

# Run specific CLI commands
./build/quip-cli --rpc-url "https://base-sepolia.g.alchemy.com/v2/your_api_key_here" --contract-address "0x4a5A444F3B12342Dc50E34f562DfFBf0152cBb99" deposit <pubkey> <sig> <private_key>

Custom Networks

When using a custom RPC_URL or CHAIN_ID, you must provide a QuipFactory contract address:

# Test against Sepolia testnet
./e2e_test.sh \
  --rpc-url "https://eth-sepolia.g.alchemy.com/v2/your_api_key_here" \
  --chain-id 11155111 \
  --quip-factory-address "0x4a5A444F3B12342Dc50E34f562DfFBf0152cBb99"

# Test against Base mainnet
./e2e_test.sh \
  --rpc-url "https://mainnet.base.org" \
  --chain-id 8453 \
  --quip-factory-address "0x4a5A444F3B12342Dc50E34f562DfFBf0152cBb99"

CLI Commands

# Deploy a new Quip wallet
./build/quip-cli --rpc-url <url> --contract-address <factory_address> deposit <pubkey> <sig> <private_key>

# Transfer funds
./build/quip-cli --rpc-url <url> --contract-address <factory_address> transfer <pubkey> <sig> <to_address> <amount> <private_key>

# Execute contract call
./build/quip-cli --rpc-url <url> --contract-address <factory_address> execute <pubkey> <sig> <target_address> <opdata> <private_key>

# Change PQ owner
./build/quip-cli --rpc-url <url> --contract-address <factory_address> change-owner <pubkey> <sig> <private_key>

# Check wallet balance
./build/quip-cli --rpc-url <url> --contract-address <factory_address> balance <address>

# Check PQ owner
./build/quip-cli --rpc-url <url> --contract-address <factory_address> pq-owner <address>

Configuration

Environment Variables

Create a .env based on the .env.example file in the ethereum-sdk directory.

Contract Addresses

For local development, contract addresses are automatically loaded from ethereum-sdk/src/addresses.json.

For custom networks, you must provide the QuipFactory contract address using the --quip-factory-address parameter.

Testing

Unit Tests

cd build && ./quip-cli-tests

End-to-End Tests

# Show E2E test help
./e2e_test.sh --help

# Local development
./e2e_test.sh

# Custom network
./e2e_test.sh --rpc-url <url> --chain-id <id> --quip-factory-address <address>

Network Requirements

Local Development

Custom Networks

Error Handling

The CLI validates:

Examples

Complete Workflow

# 1. Deploy a new wallet
./build/quip-cli --rpc-url "https://base-sepolia.g.alchemy.com/v2/your_api_key_here" --contract-address "0x4a5A444F3B12342Dc50E34f562DfFBf0152cBb99" deposit <pubkey> <sig> <private_key>

# 2. Transfer funds
./build/quip-cli --rpc-url "https://base-sepolia.g.alchemy.com/v2/your_api_key_here" --contract-address "0x4a5A444F3B12342Dc50E34f562DfFBf0152cBb99" transfer <pubkey> <sig> "0x1234..." "1000000000000000000" <private_key>

# 3. Execute contract call
./build/quip-cli --rpc-url "https://base-sepolia.g.alchemy.com/v2/your_api_key_here" --contract-address "0x4a5A444F3B12342Dc50E34f562DfFBf0152cBb99" execute <pubkey> <sig> "0x5678..." "0x12345678" <private_key>

# 4. Change owner
./build/quip-cli --rpc-url "https://base-sepolia.g.alchemy.com/v2/your_api_key_here" --contract-address "0x4a5A444F3B12342Dc50E34f562DfFBf0152cBb99" change-owner <pubkey> <sig> <private_key>

Dependencies

License

AGPL-3.0, see COPYING

cpp-sdk (QuipNetwork/cpp-sdk)

Searching Database…

11.3K ·GitHub
这是什么?Quip C++ SDK 是一个客户端库和命令行工具,用于与以太坊上的 Quip 智能合约交互,让你可以部署和管理“Quip”钱包。这些钱包使用后量子的 Winternitz 签名,而不是标准的 ECDSA 密钥。
这是库、命令行工具,还是两者都是?两者都是:它是一个 C++ SDK(用于 QuipFactory/QuipWallet 操作的库代码),同时也提供命令行界面,用于部署钱包、转账和运行测试。
我该如何构建和运行它?克隆仓库并运行 ./build.sh,它会构建 CLI 工具并运行测试套件;默认情况下,CLI 指向本地 Hardhat 网络。
构建它需要安装什么?你需要安装 CMake 3.10+、支持 C++17 的编译器、libcurl、nlohmann/json、Google Test 和 OpenSSL 3.0+;如果要进行本地测试,还需要基于 Hardhat 的 ethereum-sdk 来部署 Quip 合约。
这个 SDK 会自己生成后量子密钥吗?不会。这里不包含 Winternitz 后量子签名的密钥生成功能;你需要单独的 hashsigs-cpp 库来创建密钥对和签名。
用 CLI 我到底能对 Quip 钱包做什么?它支持 deposit(部署一个使用 Winternitz 签名的新钱包)、transfer、execute、change-owner、balance 和 pq-owner 等命令,用于管理合约所有权和资金。
我能把它指向本地 Hardhat 以外的网络吗?可以,你可以指定任何有效的以太坊 RPC 端点和链 ID;但对于自定义网络,必须通过 --quip-factory-address 提供有效的 QuipFactory 合约地址。
本地开发时合约地址是如何配置的?在本地 Hardhat 开发中,你自行部署 Deployer、WOTSPlus 和 QuipFactory 合约后,地址会自动从 ethereum-sdk/src/addresses.json 加载。
为什么要用 Winternitz 签名,而不是普通的以太坊密钥?Winternitz 一次性签名(WOTS)具有后量子安全性,因此基于它的 Quip 钱包旨在抵御未来量子计算机的攻击,这些攻击可能会破解基于 ECDSA 的标准以太坊账户。
Size
0.1 MB
Stars
11.3K
Updated
CommitJul 09
Age
1y
Commits · 90 Days