Skip to content

Commit

Permalink
feat: DID merkle proofs (#744)
Browse files Browse the repository at this point in the history
* Add type definitions for the new dipSender runtime API

* Update types with new spec 11000

* Update type definitions

* Change keyIds input type
  • Loading branch information
ntn-x2 committed Dec 13, 2023
1 parent 0e2d1f9 commit 703e087
Show file tree
Hide file tree
Showing 3 changed files with 103 additions and 2 deletions.
20 changes: 18 additions & 2 deletions packages/type-definitions/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,14 @@ import { types10410 } from './types_10410.js'
import { types10720 } from './types_10720.js'
import { types10800 } from './types_10800.js'
import { types10900 } from './types_10900.js'
import { types11000 } from './types_11000.js'

// Custom runtime calls

import { calls as didCalls } from './runtime/did.js'
import { calls as stakingCalls } from './runtime/staking.js'
import { calls as publicCredentialsCalls } from './runtime/publicCredentials.js'
import { calls as dipSenderCalls } from './runtime/dipSender.js'

export {
types8,
Expand All @@ -50,12 +52,13 @@ export {
types10720,
types10800,
types10900,
types10900 as types,
types11000 as types,
}

export { calls as didCalls } from './runtime/did.js'
export { calls as stakingCalls } from './runtime/staking.js'
export { calls as publicCredentialsCalls } from './runtime/publicCredentials.js'
export { calls as dipSenderCalls } from './runtime/dipSender.js'

const defaultTypesBundle: OverrideVersionedType[] = [
{
Expand Down Expand Up @@ -119,9 +122,13 @@ const defaultTypesBundle: OverrideVersionedType[] = [
types: types10800,
},
{
minmax: [10900, undefined],
minmax: [10900, 10999],
types: types10900,
},
{
minmax: [11000, undefined],
types: types11000,
},
]

// Current runtime version: 10730
Expand Down Expand Up @@ -174,6 +181,15 @@ export const typesBundle: OverrideBundleType = {
},
types: defaultTypesBundle,
},
'DIP sender dev': {
runtime: {
...dipSenderCalls,
},
types: defaultTypesBundle,
},
'DIP receiver dev': {
types: defaultTypesBundle,
},
Development: {
runtime: {
...didCalls,
Expand Down
33 changes: 33 additions & 0 deletions packages/type-definitions/src/runtime/dipSender.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
/**
* Copyright (c) 2018-2023, BOTLabs GmbH.
*
* This source code is licensed under the BSD 4-Clause "Original" license
* found in the LICENSE file in the root directory of this source tree.
*/

import type { DefinitionsCall } from '@polkadot/types/types'

export const calls: DefinitionsCall = {
DipSender: [
{
methods: {
generate_proof: {
description:
'Generate a Merkle proof for the DIP protocol for the specified DID and public keys.',
params: [
{
name: 'identifier',
type: 'AccountId32',
},
{
name: 'keys',
type: 'Vec<Hash>',
},
],
type: 'Result<CompleteMerkleProof, ()>',
},
},
version: 1,
},
],
}
52 changes: 52 additions & 0 deletions packages/type-definitions/src/types_11000.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
/**
* Copyright (c) 2018-2023, BOTLabs GmbH.
*
* This source code is licensed under the BSD 4-Clause "Original" license
* found in the LICENSE file in the root directory of this source tree.
*/

import type { RegistryTypes } from '@polkadot/types/types'

import { types10900 } from './types_10900.js'

export const types11000: RegistryTypes = {
...types10900,
// DipSender state_call
CompleteMerkleProof: {
root: 'MerkleRoot',
proof: 'MerkleProof',
},
MerkleRoot: 'Hash',
MerkleProof: {
blinded: 'BlindedLeaves',
revealed: 'RevealedLeaves',
},
BlindedLeaves: 'Vec<BlindedValue>',
BlindedValue: 'Bytes',
RevealedLeaves: 'Vec<RevealedLeaf>',
RevealedLeaf: {
_enum: {
KeyReference: '(KeyReferenceKey, KeyReferenceValue)',
KeyDetails: '(KeyDetailsKey, KeyDetailsValue)',
},
},
KeyReferenceKey: '(KeyId, KeyRelationship)',
KeyReferenceValue: 'Null',
KeyDetailsKey: 'KeyId',
KeyDetailsValue: 'DidDidDetailsDidPublicKeyDetails',
KeyId: 'Hash',
KeyRelationship: {
_enum: {
Encryption: 'Null',
Verification: 'VerificationRelationship',
},
},
VerificationRelationship: {
_enum: [
'Authentication',
'CapabilityDelegation',
'CapabilityInvocation',
'AssertionMethod',
],
},
}

0 comments on commit 703e087

Please sign in to comment.