# SuperWalletTrustRegistry

The contract a Super Wallet credential is checked against: issuer keys, credential anchors,
revocations, ZK commitments and registered circuits. Xphere mainnet, chain id 20250217.

| | |
|---|---|
| Address | `0x852688D815410e3FEa015FD3a07028BF6b981d80` |
| Creation tx | `0x4b19478d1c6d29d6710552988ee8ba2684f5d2327fdaa39c48f5eb37297e6ee7` |
| Runtime bytecode keccak256 | `0x71297ff897fb5570ffda13ff3acddc07c6907b6c6930512628e284d157a3b9e2` |
| Creation bytecode keccak256 | `0x8dc69c7e939701e522ce83b235d58d4399ef1c9c4d14178d24524b050123c115` |
| Compiler | solc 0.8.24+commit.e11b9ed9, optimizer on (200 runs), evmVersion paris, no viaIR |
| RPC | `https://en-hkg.x-phere.com` |
| Explorer | `https://xp.tamsa.io/address/0x852688D815410e3FEa015FD3a07028BF6b981d80` |

## Files

| File | What it is |
|---|---|
| `SuperWalletTrustRegistry.sol` | The source (no imports, no dependencies) |
| `SuperWalletTrustRegistry.json` | ABI, compiler settings and the two bytecode hashes above |
| `solc-input.json` | The exact solc standard-JSON input the deployed contract was compiled from |
| `hardhat.config.cjs` | The Hardhat configuration of the repository project (`chain/trust-registry`) |
| `check-bytecode.cjs`, `keccak.cjs` | Compare a compilation with the chain (Node 18+, no packages) |

## Reproduce the bytecode

No Hardhat needed; solc-js is fetched by npx:

```bash
npx --yes solc@0.8.24 --standard-json < solc-input.json > solc-output.json
node check-bytecode.cjs solc-output.json contracts/SuperWalletTrustRegistry.sol:SuperWalletTrustRegistry \
  0x852688D815410e3FEa015FD3a07028BF6b981d80 \
  0x4b19478d1c6d29d6710552988ee8ba2684f5d2327fdaa39c48f5eb37297e6ee7
```

It prints the keccak256 of the compiled runtime and creation code, of the code at the address
(`eth_getCode`) and of the creation transaction's input, and exits 1 if any differ. The contract has
no immutables and no constructor arguments, so the deployed runtime code equals the compiler output
including its metadata hash, and the metadata hash changes if even a comment in the source changes.

From the repository instead: `cd chain/trust-registry && npm ci && npx hardhat compile && node scripts/export-abi.cjs`
prints the same two hashes.

## Reading it

| View | Returns |
|---|---|
| `credential(bytes32 credentialId)` | `digest, issuerId, anchoredAt, revokedAt, reason` |
| `issuer(bytes32 issuerId)` | `keyFingerprint, did, status (0 none, 1 active, 2 suspended), since` |
| `commitment(bytes32 credentialId, bytes32 circuitId)` | `uint256` (0 = none) |
| `circuit(bytes32 circuitId)` | `verifier, vkHash, contributions, uri` |

`credentialId = keccak256(utf8(vc.id))`, `issuerId = keccak256(utf8(issuer DID))`,
`circuitId = keccak256(utf8(circuit name))`, `digest = sha256(JCS(credential without "proof"))`
(RFC 8785), `keyFingerprint` = RFC 7638 SHA-256 thumbprint of the issuer's signing JWK. Reason codes:
0 unspecified, 1 revoked by the issuer, 2 superseded.

Registered issuers today: `did:web:trendy.storydot.kr` and `did:sw:issuer`, both with key fingerprint
`0x7397cf6af4af2df8c5f8fd0367c7083509393ea26c63910d96489d9bd0a6b33c` (the `#es256-1` key in
`https://trendy.storydot.kr/.well-known/did.json`).

The `<sw-verify>` widget and `@superwallet/verifier-sdk`'s `verify()` do these reads for you; see
`https://trendy.storydot.kr/sdk/`.
