@pvium/p2id-core 0.1.2 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/contracts/P2IDVault.sol +320 -214
- package/contracts/PviumIdentity.sol +29 -36
- package/contracts/PviumP2IDPolicy.sol +4 -7
- package/contracts/PviumP2IDVaultProxy.sol +199 -0
- package/contracts/PviumP2IdVaultFactory.sol +346 -34
- package/contracts/PviumVerifier.sol +15 -21
- package/contracts/PviumZKVerifier.sol +137 -111
- package/contracts/interfaces/IP2IDPolicy.sol +5 -21
- package/contracts/interfaces/IP2IDVault.sol +42 -17
- package/contracts/interfaces/IP2IDVaultProxy.sol +42 -0
- package/contracts/interfaces/IP2IDVerifier.sol +12 -13
- package/contracts/interfaces/IP2IdVaultFactory.sol +41 -7
- package/contracts/interfaces/IPviumIdentity.sol +6 -7
- package/contracts/lib/P2IDHash.sol +5 -5
- package/dist/cjs/p2idConstants.js +2 -2
- package/dist/esm/p2idConstants.d.ts +2 -2
- package/dist/esm/p2idConstants.js +2 -2
- package/package.json +1 -1
|
@@ -2,9 +2,11 @@
|
|
|
2
2
|
pragma solidity ^0.8.27;
|
|
3
3
|
|
|
4
4
|
/// @title IP2IDVerifier
|
|
5
|
-
/// @notice
|
|
6
|
-
/// identity resolves to. Optionally also verify a funding constraint.
|
|
5
|
+
/// @notice Resolve an identity proof to a wallet and issue time, with optional constraint evidence.
|
|
7
6
|
interface IP2IDVerifier {
|
|
7
|
+
/// @notice Trusted key-artifact SHA-256 pinned by this verifier; never read from caller metadata.
|
|
8
|
+
function vkHash() external view returns (bytes32);
|
|
9
|
+
|
|
8
10
|
/// @notice A funding constraint and the evidence that it is satisfied.
|
|
9
11
|
/// @param commitment bytes32(0) = no constraint; otherwise the commitment a deposit was funded with.
|
|
10
12
|
/// @param signature Evidence for `commitment`; for PviumVerifier, the registered signer's
|
|
@@ -15,9 +17,7 @@ interface IP2IDVerifier {
|
|
|
15
17
|
bytes signature;
|
|
16
18
|
}
|
|
17
19
|
|
|
18
|
-
/// @param identityHash
|
|
19
|
-
/// commitment). Proofs are public once used on-chain, so the caller MUST
|
|
20
|
-
/// pin the identity rather than trust whatever the submitted proof proves.
|
|
20
|
+
/// @param identityHash Expected identity commitment that the implementation must match against the proof.
|
|
21
21
|
/// @param proof Opaque identity proof; the implementation defines the encoding.
|
|
22
22
|
/// @param constraint Skipped when `constraint.commitment == bytes32(0)`.
|
|
23
23
|
/// @return wallet Wallet associated with the proven identity (never address(0)).
|
|
@@ -30,15 +30,14 @@ interface IP2IDVerifier {
|
|
|
30
30
|
Constraint calldata constraint
|
|
31
31
|
) external view returns (address wallet, uint64 iat);
|
|
32
32
|
|
|
33
|
-
/// @notice Whether this verifier
|
|
34
|
-
///
|
|
35
|
-
///
|
|
33
|
+
/// @notice Whether this verifier currently supports nonzero constraints. P2IDVault requires
|
|
34
|
+
/// a successful true response when funding a constrained deposit; this does not establish
|
|
35
|
+
/// that any particular commitment can be satisfied.
|
|
36
36
|
function supportsConstraints() external view returns (bool);
|
|
37
37
|
|
|
38
|
-
/// @notice
|
|
39
|
-
///
|
|
40
|
-
///
|
|
41
|
-
///
|
|
42
|
-
/// nothing this verifier trusts can ever be revoked.
|
|
38
|
+
/// @notice Cache revision. Implementations must increment it when previously accepted identity
|
|
39
|
+
/// proofs may no longer be trusted, or return a constant if trust cannot be revoked.
|
|
40
|
+
/// @dev P2IDVault rejects cached-owner claims when this differs from the stored revision, and
|
|
41
|
+
/// rejects cached-owner claims and proof updates when the revision cannot be read.
|
|
43
42
|
function revision() external view returns (uint64);
|
|
44
43
|
}
|
|
@@ -2,30 +2,64 @@
|
|
|
2
2
|
pragma solidity ^0.8.27;
|
|
3
3
|
|
|
4
4
|
/// @title IP2IdVaultFactory
|
|
5
|
-
/// @notice
|
|
6
|
-
/// identity hash, and points every vault at the current policy and default verifier.
|
|
5
|
+
/// @notice Vault proxy deployment, address derivation, funding and shared configuration views.
|
|
7
6
|
interface IP2IdVaultFactory {
|
|
8
7
|
event VaultDeployed(bytes32 indexed identityHash, address indexed vault);
|
|
8
|
+
event ImplementationProposed(address indexed implementation, uint64 eta);
|
|
9
|
+
event ImplementationProposalCancelled(address indexed implementation);
|
|
10
|
+
event ImplementationRegistered(address indexed implementation);
|
|
11
|
+
event ImplementationDeployed(address indexed implementation, bytes32 creationCodeHash);
|
|
12
|
+
event ImplementationDefaultProposed(address indexed implementation, bool makeDefault, uint64 eta);
|
|
13
|
+
event DefaultImplementationActivated(address indexed implementation);
|
|
14
|
+
event ImplementationRevoked(address indexed implementation);
|
|
9
15
|
|
|
10
16
|
/// @notice P2ID factory interface version implemented by this contract.
|
|
11
17
|
function p2idVersion() external pure returns (string memory);
|
|
12
18
|
|
|
13
|
-
// ----
|
|
14
|
-
/// @notice
|
|
19
|
+
// ---- shared configuration ----
|
|
20
|
+
/// @notice Policy address used for verifier approval, fee quotes and fee distribution.
|
|
15
21
|
function policy() external view returns (address);
|
|
16
22
|
/// @notice Verifier used when a payer does not choose one, and the one bare transfers are claimed through.
|
|
17
23
|
function defaultVerifier() external view returns (address);
|
|
24
|
+
/// @notice Whether proofs under `vkHash` need an alpha attestation: true for every key until released.
|
|
25
|
+
function isAlpha(bytes32 vkHash) external view returns (bool);
|
|
26
|
+
function setDefaultAttester(address attester) external;
|
|
27
|
+
function defaultAttester() external view returns (address);
|
|
28
|
+
function alphaRevision(bytes32 vkHash) external view returns (uint256);
|
|
29
|
+
function alphaEpoch() external view returns (uint256);
|
|
30
|
+
function verifyAlphaAuthorization(address vault, address caller, bytes32 callHash, uint256 nonce, uint256 deadline, bytes calldata signature) external view;
|
|
31
|
+
|
|
32
|
+
// ---- vault implementations ----
|
|
33
|
+
/// @notice The implementation every newly deployed vault proxy starts on.
|
|
34
|
+
function baseImplementation() external view returns (address);
|
|
35
|
+
/// @notice Whether the implementation is registered as an upgrade target; other upgrade checks also apply.
|
|
36
|
+
function isRegisteredImplementation(address implementation) external view returns (bool);
|
|
37
|
+
|
|
38
|
+
function initialImplementation() external view returns (address);
|
|
39
|
+
function implementationFor(bytes32 creationCodeHash) external view returns (address);
|
|
40
|
+
/// @notice Deploy full creation code and propose registration; makeDefault applies after the delay.
|
|
41
|
+
function deployVaultImplementation(bytes memory creationCode, bool makeDefault) external returns (address);
|
|
42
|
+
function proposeDefaultImplementation(address implementation) external;
|
|
43
|
+
|
|
44
|
+
// ---- address derivation constants ----
|
|
45
|
+
/// @notice Namespace value supplied to the factory constructor and passed to vault initialization.
|
|
46
|
+
function nsHash() external view returns (bytes32);
|
|
47
|
+
/// @notice Proxy creation-code hash used with this factory's address and an identityHash for CREATE2 derivation.
|
|
48
|
+
function initCodeHash() external pure returns (bytes32);
|
|
49
|
+
/// @notice Refund-window bounds passed to new vaults during initialization.
|
|
50
|
+
function minRefundWindow() external view returns (uint64);
|
|
51
|
+
function maxRefundWindow() external view returns (uint64);
|
|
18
52
|
|
|
19
53
|
// ---- vaults ----
|
|
20
54
|
/// @notice The vault address for `identityHash`, deployed or not:
|
|
21
|
-
/// `keccak256(0xff
|
|
55
|
+
/// Low 160 bits of `keccak256(0xff || factory || identityHash || initCodeHash())`.
|
|
22
56
|
function vaultFor(bytes32 identityHash) external view returns (address);
|
|
23
57
|
function isDeployed(bytes32 identityHash) external view returns (bool);
|
|
24
58
|
/// @notice Deploy the vault for `identityHash`; returns the existing one if already deployed.
|
|
25
59
|
function deploy(bytes32 identityHash) external returns (address vault);
|
|
26
60
|
/// @notice Deploy if needed, then fund under the default verifier on the caller's behalf
|
|
27
|
-
/// (caller
|
|
28
|
-
///
|
|
61
|
+
/// (caller is recorded as funder). ERC-20: approve this factory for the requested amount.
|
|
62
|
+
/// Native coin: token = address(0), send `amount` as msg.value.
|
|
29
63
|
/// @param ref Opaque application reference forwarded to the vault's Funded event; bytes32(0) for none.
|
|
30
64
|
function fund(
|
|
31
65
|
bytes32 identityHash,
|
|
@@ -2,19 +2,18 @@
|
|
|
2
2
|
pragma solidity ^0.8.27;
|
|
3
3
|
|
|
4
4
|
/// @title IPviumIdentity
|
|
5
|
-
/// @notice
|
|
6
|
-
///
|
|
7
|
-
/// signed by one of the accepted keys, and binds exactly the values given. The return value is
|
|
8
|
-
/// when Privy issued that token (unix seconds); freshness policy is the caller's.
|
|
5
|
+
/// @notice Attestation verification and signer/version views exposed by PviumIdentity.
|
|
6
|
+
/// verifyIdentity checks the supplied identity type, identity hash and wallet hash.
|
|
9
7
|
interface IPviumIdentity {
|
|
10
8
|
/// @notice Circuit version this deployment verifies. Attestations state theirs; use the matching deployment.
|
|
9
|
+
function vkHash() external view returns (bytes32);
|
|
11
10
|
function circuitVersion() external view returns (uint16);
|
|
12
|
-
/// @notice Whether
|
|
11
|
+
/// @notice Whether this P-256 key belongs to the deployment's current accepted signer set.
|
|
13
12
|
function isSignerKey(uint256 x, uint256 y) external view returns (bool);
|
|
14
13
|
|
|
15
14
|
/// @notice Verify that the proof binds exactly this identity and this wallet.
|
|
16
|
-
/// @dev
|
|
17
|
-
///
|
|
15
|
+
/// @dev The expected identity and wallet are supplied as hashes. The function does not impose
|
|
16
|
+
/// an age limit on the attestation.
|
|
18
17
|
/// @param identityType Identity type id: 0 email, 3 twitter, 5 github, … (see P2IDHash)
|
|
19
18
|
/// @param identityHash P2IDHash.identityHash(identityType, value)
|
|
20
19
|
/// @param walletHash P2IDHash.walletHash(wallet): an address, or a string for a non-EVM wallet
|
|
@@ -2,10 +2,10 @@
|
|
|
2
2
|
pragma solidity ^0.8.27;
|
|
3
3
|
|
|
4
4
|
/// @title P2IDHash
|
|
5
|
-
/// @notice
|
|
5
|
+
/// @notice Identity commitment:
|
|
6
6
|
/// sha256("p2id.identity.v1" || identityType || normalize(value)).
|
|
7
|
-
///
|
|
8
|
-
///
|
|
7
|
+
/// Normalization ASCII-lowercases non-phone, non-wallet values. Wallet values are
|
|
8
|
+
/// lowercased only when they start with lowercase `0x`; other wallet strings are unchanged.
|
|
9
9
|
library P2IDHash {
|
|
10
10
|
bytes internal constant PREFIX = "p2id.identity.v1";
|
|
11
11
|
uint8 internal constant PHONE = 1;
|
|
@@ -27,7 +27,7 @@ library P2IDHash {
|
|
|
27
27
|
return sha256(abi.encodePacked(PREFIX, WALLET, toLowerHex(wallet)));
|
|
28
28
|
}
|
|
29
29
|
|
|
30
|
-
/// @notice
|
|
30
|
+
/// @notice Wallet-string commitment using type 12, with identityHash's normalization and length checks.
|
|
31
31
|
function walletHash(string memory wallet) internal pure returns (bytes32) {
|
|
32
32
|
return identityHash(WALLET, bytes(wallet));
|
|
33
33
|
}
|
|
@@ -48,7 +48,7 @@ library P2IDHash {
|
|
|
48
48
|
return out;
|
|
49
49
|
}
|
|
50
50
|
|
|
51
|
-
/// @dev "0x"
|
|
51
|
+
/// @dev Encode an address as "0x" followed by 40 lowercase hexadecimal characters.
|
|
52
52
|
function toLowerHex(address a) internal pure returns (bytes memory out) {
|
|
53
53
|
bytes16 digits = "0123456789abcdef";
|
|
54
54
|
out = new bytes(42);
|
|
@@ -5,10 +5,10 @@ exports.P2ID_SCHEME = exports.P2ID_SCHEMES = void 0;
|
|
|
5
5
|
exports.P2ID_SCHEMES = {
|
|
6
6
|
"pvium.vault.v1": {
|
|
7
7
|
"identityDomain": "p2id.identity.v1",
|
|
8
|
-
"vaultInitCodeHash": "
|
|
8
|
+
"vaultInitCodeHash": "0x23dec57677be79edb9ad208117422435778ee00c12d4c56e2edf226d2a57b18a",
|
|
9
9
|
"factories": {
|
|
10
10
|
"production": null,
|
|
11
|
-
"sandbox": "
|
|
11
|
+
"sandbox": "0x48fD1bc4f982342dCFe2BEAc5fCFd22b4c1Ba4f6"
|
|
12
12
|
}
|
|
13
13
|
}
|
|
14
14
|
};
|
|
@@ -18,10 +18,10 @@ export interface P2IDScheme {
|
|
|
18
18
|
export declare const P2ID_SCHEMES: {
|
|
19
19
|
readonly "pvium.vault.v1": {
|
|
20
20
|
readonly identityDomain: "p2id.identity.v1";
|
|
21
|
-
readonly vaultInitCodeHash: "
|
|
21
|
+
readonly vaultInitCodeHash: "0x23dec57677be79edb9ad208117422435778ee00c12d4c56e2edf226d2a57b18a";
|
|
22
22
|
readonly factories: {
|
|
23
23
|
readonly production: null;
|
|
24
|
-
readonly sandbox: "
|
|
24
|
+
readonly sandbox: "0x48fD1bc4f982342dCFe2BEAc5fCFd22b4c1Ba4f6";
|
|
25
25
|
};
|
|
26
26
|
};
|
|
27
27
|
};
|
|
@@ -2,10 +2,10 @@
|
|
|
2
2
|
export const P2ID_SCHEMES = {
|
|
3
3
|
"pvium.vault.v1": {
|
|
4
4
|
"identityDomain": "p2id.identity.v1",
|
|
5
|
-
"vaultInitCodeHash": "
|
|
5
|
+
"vaultInitCodeHash": "0x23dec57677be79edb9ad208117422435778ee00c12d4c56e2edf226d2a57b18a",
|
|
6
6
|
"factories": {
|
|
7
7
|
"production": null,
|
|
8
|
-
"sandbox": "
|
|
8
|
+
"sandbox": "0x48fD1bc4f982342dCFe2BEAc5fCFd22b4c1Ba4f6"
|
|
9
9
|
}
|
|
10
10
|
}
|
|
11
11
|
};
|
package/package.json
CHANGED