Skip to content

Commit 1fa370e

Browse files
committed
#524 Revocation of NOC root certificates
Enable revoking NOC Root certs Signed-off-by: Abdulbois <abdulbois.tursunov@dsr-corporation.com> Signed-off-by: Abdulbois <abdulbois123@gmail.com>
1 parent 252b7ee commit 1fa370e

37 files changed

+4344
-288
lines changed

proto/pki/genesis.proto

+2
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ import "pki/pki_revocation_distribution_points_by_issuer_subject_key_id.proto";
1616
import "pki/approved_certificates_by_subject_key_id.proto";
1717
import "pki/noc_root_certificates.proto";
1818
import "pki/noc_certificates.proto";
19+
import "pki/revoked_noc_root_certificates.proto";
1920
// this line is used by starport scaffolding # genesis/proto/import
2021
import "gogoproto/gogo.proto";
2122

@@ -38,5 +39,6 @@ message GenesisState {
3839
repeated ApprovedCertificatesBySubjectKeyId approvedCertificatesBySubjectKeyIdList = 13 [(gogoproto.nullable) = false];
3940
repeated NocRootCertificates nocRootCertificatesList = 14 [(gogoproto.nullable) = false];
4041
repeated NocCertificates nocCertificatesList = 15 [(gogoproto.nullable) = false];
42+
repeated RevokedNocRootCertificates revokedNocRootCertificatesList = 16 [(gogoproto.nullable) = false];
4143
// this line is used by starport scaffolding # genesis/proto/state
4244
}

proto/pki/query.proto

+29
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ import "pki/pki_revocation_distribution_point.proto";
1616
import "pki/pki_revocation_distribution_points_by_issuer_subject_key_id.proto";
1717
import "pki/noc_root_certificates.proto";
1818
import "pki/noc_certificates.proto";
19+
import "pki/revoked_noc_root_certificates.proto";
1920
// this line is used by starport scaffolding # 1
2021
import "gogoproto/gogo.proto";
2122

@@ -131,6 +132,16 @@ service Query {
131132
option (google.api.http).get = "/dcl/pki/noc-certificates";
132133
}
133134

135+
// Queries a RevokedNocRootCertificates by index.
136+
rpc RevokedNocRootCertificates(QueryGetRevokedNocRootCertificatesRequest) returns (QueryGetRevokedNocRootCertificatesResponse) {
137+
option (google.api.http).get = "/dcl/pki/revoked-noc-root-certificates/{subject}/{subjectKeyId}";
138+
}
139+
140+
// Queries a list of RevokedNocRootCertificates items.
141+
rpc RevokedNocRootCertificatesAll(QueryAllRevokedNocRootCertificatesRequest) returns (QueryAllRevokedNocRootCertificatesResponse) {
142+
option (google.api.http).get = "/dcl/pki/revoked-noc-root-certificates";
143+
}
144+
134145
// this line is used by starport scaffolding # 2
135146
}
136147

@@ -323,4 +334,22 @@ message QueryAllNocCertificatesResponse {
323334
cosmos.base.query.v1beta1.PageResponse pagination = 2;
324335
}
325336

337+
message QueryGetRevokedNocRootCertificatesRequest {
338+
string subject = 1;
339+
string subjectKeyId = 2;
340+
}
341+
342+
message QueryGetRevokedNocRootCertificatesResponse {
343+
RevokedNocRootCertificates revokedNocRootCertificates = 1 [(gogoproto.nullable) = false];
344+
}
345+
346+
message QueryAllRevokedNocRootCertificatesRequest {
347+
cosmos.base.query.v1beta1.PageRequest pagination = 1;
348+
}
349+
350+
message QueryAllRevokedNocRootCertificatesResponse {
351+
repeated RevokedNocRootCertificates revokedNocRootCertificates = 1 [(gogoproto.nullable) = false];
352+
cosmos.base.query.v1beta1.PageResponse pagination = 2;
353+
}
354+
326355
// this line is used by starport scaffolding # 3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
syntax = "proto3";
2+
package zigbeealliance.distributedcomplianceledger.pki;
3+
4+
option go_package = "github.com/zigbee-alliance/distributed-compliance-ledger/x/pki/types";
5+
6+
import "pki/certificate.proto";
7+
8+
message RevokedNocRootCertificates {
9+
string subject = 1;
10+
string subjectKeyId = 2;
11+
repeated Certificate certs = 3;
12+
}

proto/pki/tx.proto

+14
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ service Msg {
2424
rpc AddNocX509RootCert(MsgAddNocX509RootCert) returns (MsgAddNocX509RootCertResponse);
2525
rpc RemoveX509Cert(MsgRemoveX509Cert) returns (MsgRemoveX509CertResponse);
2626
rpc AddNocX509Cert(MsgAddNocX509Cert) returns (MsgAddNocX509CertResponse);
27+
rpc RevokeNocRootX509Cert(MsgRevokeNocRootX509Cert) returns (MsgRevokeNocRootX509CertResponse);
2728
// this line is used by starport scaffolding # proto/tx/rpc
2829
}
2930

@@ -187,4 +188,17 @@ message MsgAddNocX509Cert {
187188
message MsgAddNocX509CertResponse {
188189
}
189190

191+
message MsgRevokeNocRootX509Cert {
192+
string signer = 1 [(cosmos_proto.scalar) = "cosmos.AddressString", (gogoproto.moretags) = "validate:\"required\""];
193+
string subject = 2 [(gogoproto.moretags) = "validate:\"required,max=1024\""];
194+
string subjectKeyId = 3 [(gogoproto.moretags) = "validate:\"required,max=256\""];
195+
string serialNumber = 4;
196+
string info = 5 [(gogoproto.moretags) = "validate:\"max=4096\""];
197+
int64 time = 6;
198+
bool revokeChild = 7;
199+
}
200+
201+
message MsgRevokeNocRootX509CertResponse {
202+
}
203+
190204
// this line is used by starport scaffolding # proto/tx/message

scripts/starport/upgrade-0.44/07.pki_types.sh

+2
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ starport scaffold --module pki message update-pki-revocation-distribution-point
1919
starport scaffold --module pki message delete-pki-revocation-distribution-point vid:uint label issuerSubjectKeyID --signer signer
2020
starport scaffold --module pki message AddNocX509RootCert cert --signer signer
2121
starport scaffold --module pki message AddNocX509Cert cert --signer signer
22+
starport scaffold --module pki message RevokeNocRootX509Cert subject subjectKeyId serialNumber info time:uint revokeChild:bool --signer signer
2223

2324
# CRUD data types
2425
starport scaffold --module pki map ApprovedCertificates certs:strings --index subject,subjectKeyId --no-message
@@ -37,6 +38,7 @@ starport scaffold --module pki map RejectedCertificate pemCert serialNumber owne
3738
#starport scaffold --module pki map AllProposedCertificates --index subject,subjectKeyId --no-message
3839
starport scaffold --module pki map NocRootCertificates certs:strings --index vid:uint --no-message
3940
starport scaffold --module pki map NocCertificates certs:strings --index vid:uint --no-message
41+
starport scaffold --module pki map RevokedNocRootCertificates certs:strings --index subject,subjectKeyId --no-message
4042

4143
# Allow colons (:) in subject ID part in REST URLs
4244
# TODO: need to copy the generated query.pb.gw.go into the correct folder

vue/src/store/generated/zigbee-alliance/distributed-compliance-ledger/zigbeealliance.distributedcomplianceledger.pki/index.ts

+66-2
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,12 @@ import { ProposedCertificate } from "./module/types/pki/proposed_certificate"
1818
import { ProposedCertificateRevocation } from "./module/types/pki/proposed_certificate_revocation"
1919
import { RejectedCertificate } from "./module/types/pki/rejected_certificate"
2020
import { RevokedCertificates } from "./module/types/pki/revoked_certificates"
21+
import { RevokedNocRootCertificates } from "./module/types/pki/revoked_noc_root_certificates"
2122
import { RevokedRootCertificates } from "./module/types/pki/revoked_root_certificates"
2223
import { UniqueCertificate } from "./module/types/pki/unique_certificate"
2324

2425

25-
export { ApprovedCertificates, ApprovedCertificatesBySubject, ApprovedCertificatesBySubjectKeyId, ApprovedRootCertificates, Certificate, CertificateIdentifier, ChildCertificates, Grant, NocCertificates, NocRootCertificates, PkiRevocationDistributionPoint, PkiRevocationDistributionPointsByIssuerSubjectKeyID, ProposedCertificate, ProposedCertificateRevocation, RejectedCertificate, RevokedCertificates, RevokedRootCertificates, UniqueCertificate };
26+
export { ApprovedCertificates, ApprovedCertificatesBySubject, ApprovedCertificatesBySubjectKeyId, ApprovedRootCertificates, Certificate, CertificateIdentifier, ChildCertificates, Grant, NocCertificates, NocRootCertificates, PkiRevocationDistributionPoint, PkiRevocationDistributionPointsByIssuerSubjectKeyID, ProposedCertificate, ProposedCertificateRevocation, RejectedCertificate, RevokedCertificates, RevokedNocRootCertificates, RevokedRootCertificates, UniqueCertificate };
2627

2728
async function initTxClient(vuexGetters) {
2829
return await txClient(vuexGetters['common/wallet/signer'], {
@@ -81,6 +82,8 @@ const getDefaultState = () => {
8182
NocRootCertificatesAll: {},
8283
NocCertificates: {},
8384
NocCertificatesAll: {},
85+
RevokedNocRootCertificates: {},
86+
RevokedNocRootCertificatesAll: {},
8487

8588
_Structure: {
8689
ApprovedCertificates: getStructure(ApprovedCertificates.fromPartial({})),
@@ -99,6 +102,7 @@ const getDefaultState = () => {
99102
ProposedCertificateRevocation: getStructure(ProposedCertificateRevocation.fromPartial({})),
100103
RejectedCertificate: getStructure(RejectedCertificate.fromPartial({})),
101104
RevokedCertificates: getStructure(RevokedCertificates.fromPartial({})),
105+
RevokedNocRootCertificates: getStructure(RevokedNocRootCertificates.fromPartial({})),
102106
RevokedRootCertificates: getStructure(RevokedRootCertificates.fromPartial({})),
103107
UniqueCertificate: getStructure(UniqueCertificate.fromPartial({})),
104108

@@ -255,6 +259,18 @@ export default {
255259
}
256260
return state.NocCertificatesAll[JSON.stringify(params)] ?? {}
257261
},
262+
getRevokedNocRootCertificates: (state) => (params = { params: {}}) => {
263+
if (!(<any> params).query) {
264+
(<any> params).query=null
265+
}
266+
return state.RevokedNocRootCertificates[JSON.stringify(params)] ?? {}
267+
},
268+
getRevokedNocRootCertificatesAll: (state) => (params = { params: {}}) => {
269+
if (!(<any> params).query) {
270+
(<any> params).query=null
271+
}
272+
return state.RevokedNocRootCertificatesAll[JSON.stringify(params)] ?? {}
273+
},
258274

259275
getTypeStructure: (state) => (type) => {
260276
return state._Structure[type].fields
@@ -787,7 +803,55 @@ export default {
787803
},
788804

789805

790-
async sendMsgRevokeX509Cert({ rootGetters }, { value, fee = [], memo = '' }) {
806+
807+
808+
809+
810+
811+
async QueryRevokedNocRootCertificates({ commit, rootGetters, getters }, { options: { subscribe, all} = { subscribe:false, all:false}, params, query=null }) {
812+
try {
813+
const key = params ?? {};
814+
const queryClient=await initQueryClient(rootGetters)
815+
let value= (await queryClient.queryRevokedNocRootCertificates( key.subject, key.subjectKeyId)).data
816+
817+
818+
commit('QUERY', { query: 'RevokedNocRootCertificates', key: { params: {...key}, query}, value })
819+
if (subscribe) commit('SUBSCRIBE', { action: 'QueryRevokedNocRootCertificates', payload: { options: { all }, params: {...key},query }})
820+
return getters['getRevokedNocRootCertificates']( { params: {...key}, query}) ?? {}
821+
} catch (e) {
822+
throw new SpVuexError('QueryClient:QueryRevokedNocRootCertificates', 'API Node Unavailable. Could not perform query: ' + e.message)
823+
824+
}
825+
},
826+
827+
828+
829+
830+
831+
832+
833+
async QueryRevokedNocRootCertificatesAll({ commit, rootGetters, getters }, { options: { subscribe, all} = { subscribe:false, all:false}, params, query=null }) {
834+
try {
835+
const key = params ?? {};
836+
const queryClient=await initQueryClient(rootGetters)
837+
let value= (await queryClient.queryRevokedNocRootCertificatesAll(query)).data
838+
839+
840+
while (all && (<any> value).pagination && (<any> value).pagination.next_key!=null) {
841+
let next_values=(await queryClient.queryRevokedNocRootCertificatesAll({...query, 'pagination.key':(<any> value).pagination.next_key})).data
842+
value = mergeResults(value, next_values);
843+
}
844+
commit('QUERY', { query: 'RevokedNocRootCertificatesAll', key: { params: {...key}, query}, value })
845+
if (subscribe) commit('SUBSCRIBE', { action: 'QueryRevokedNocRootCertificatesAll', payload: { options: { all }, params: {...key},query }})
846+
return getters['getRevokedNocRootCertificatesAll']( { params: {...key}, query}) ?? {}
847+
} catch (e) {
848+
throw new SpVuexError('QueryClient:QueryRevokedNocRootCertificatesAll', 'API Node Unavailable. Could not perform query: ' + e.message)
849+
850+
}
851+
},
852+
853+
854+
async sendMsgAddNocX509Cert({ rootGetters }, { value, fee = [], memo = '' }) {
791855
try {
792856
const txClient=await initTxClient(rootGetters)
793857
const msg = await txClient.msgRejectAddX509RootCert(value)

vue/src/store/generated/zigbee-alliance/distributed-compliance-ledger/zigbeealliance.distributedcomplianceledger.pki/module/index.ts

+3
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ import { MsgApproveRevokeX509RootCert } from "./types/pki/tx";
1818
import { MsgProposeRevokeX509RootCert } from "./types/pki/tx";
1919
import { MsgRemoveX509Cert } from "./types/pki/tx";
2020
import { MsgAddNocX509Cert } from "./types/pki/tx";
21+
import { MsgRevokeNocRootX509Cert } from "./types/pki/tx";
2122

2223

2324
const types = [
@@ -35,6 +36,7 @@ const types = [
3536
["/zigbeealliance.distributedcomplianceledger.pki.MsgProposeRevokeX509RootCert", MsgProposeRevokeX509RootCert],
3637
["/zigbeealliance.distributedcomplianceledger.pki.MsgRemoveX509Cert", MsgRemoveX509Cert],
3738
["/zigbeealliance.distributedcomplianceledger.pki.MsgAddNocX509Cert", MsgAddNocX509Cert],
39+
["/zigbeealliance.distributedcomplianceledger.pki.MsgRevokeNocRootX509Cert", MsgRevokeNocRootX509Cert],
3840
];
3941
export const MissingWalletError = new Error("wallet is required");
4042

@@ -80,6 +82,7 @@ const txClient = async (wallet: OfflineSigner, { addr: addr }: TxClientOptions =
8082
msgProposeRevokeX509RootCert: (data: MsgProposeRevokeX509RootCert): EncodeObject => ({ typeUrl: "/zigbeealliance.distributedcomplianceledger.pki.MsgProposeRevokeX509RootCert", value: MsgProposeRevokeX509RootCert.fromPartial( data ) }),
8183
msgRemoveX509Cert: (data: MsgRemoveX509Cert): EncodeObject => ({ typeUrl: "/zigbeealliance.distributedcomplianceledger.pki.MsgRemoveX509Cert", value: MsgRemoveX509Cert.fromPartial( data ) }),
8284
msgAddNocX509Cert: (data: MsgAddNocX509Cert): EncodeObject => ({ typeUrl: "/zigbeealliance.distributedcomplianceledger.pki.MsgAddNocX509Cert", value: MsgAddNocX509Cert.fromPartial( data ) }),
85+
msgRevokeNocRootX509Cert: (data: MsgRevokeNocRootX509Cert): EncodeObject => ({ typeUrl: "/zigbeealliance.distributedcomplianceledger.pki.MsgRevokeNocRootX509Cert", value: MsgRevokeNocRootX509Cert.fromPartial( data ) }),
8386
};
8487
};
8588

vue/src/store/generated/zigbee-alliance/distributed-compliance-ledger/zigbeealliance.distributedcomplianceledger.pki/module/rest.ts

+68
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,12 @@ export interface PkiNocCertificates {
3636
certs?: PkiCertificate[];
3737
}
3838

39+
export interface PkiRevokedNocRootCertificates {
40+
subject?: string;
41+
subjectKeyId?: string;
42+
certs?: PkiCertificate[];
43+
}
44+
3945
export interface PkiCertificate {
4046
pemCert?: string;
4147
serialNumber?: string;
@@ -99,6 +105,8 @@ export type PkiMsgRejectAddX509RootCertResponse = object;
99105

100106
export type PkiMsgRemoveX509CertResponse = object;
101107

108+
export type PkiMsgRevokeNocRootX509CertResponse = object;
109+
102110
export type PkiMsgRevokeX509CertResponse = object;
103111

104112
export type PkiMsgUpdatePkiRevocationDistributionPointResponse = object;
@@ -274,6 +282,21 @@ export interface PkiQueryAllRevokedCertificatesResponse {
274282
pagination?: V1Beta1PageResponse;
275283
}
276284

285+
export interface PkiQueryAllRevokedNocRootCertificatesResponse {
286+
revokedNocRootCertificates?: PkiRevokedNocRootCertificates[];
287+
288+
/**
289+
* PageResponse is to be embedded in gRPC response messages where the
290+
* corresponding request message has used PageRequest.
291+
*
292+
* message SomeResponse {
293+
* repeated Bar results = 1;
294+
* PageResponse page = 2;
295+
* }
296+
*/
297+
pagination?: V1Beta1PageResponse;
298+
}
299+
277300
export interface PkiQueryGetApprovedCertificatesBySubjectResponse {
278301
approvedCertificatesBySubject?: PkiApprovedCertificatesBySubject;
279302
}
@@ -294,6 +317,9 @@ export interface PkiQueryGetNocRootCertificatesResponse {
294317
nocRootCertificates?: PkiNocRootCertificates;
295318
}
296319

320+
export interface PkiQueryGetRevokedNocRootCertificatesResponse {
321+
revokedNocRootCertificates?: PkiRevokedNocRootCertificates;
322+
}
297323
export interface PkiQueryGetNocCertificatesResponse {
298324
nocCertificates?: PkiNocRootCertificates;
299325
}
@@ -1008,6 +1034,48 @@ export class Api<SecurityDataType extends unknown> extends HttpClient<SecurityDa
10081034
...params,
10091035
});
10101036

1037+
/**
1038+
* No description
1039+
*
1040+
* @tags Query
1041+
* @name QueryRevokedNocRootCertificatesAll
1042+
* @summary Queries a list of RevokedNocRootCertificates items.
1043+
* @request GET:/dcl/pki/revoked-noc-root-certificates
1044+
*/
1045+
queryRevokedNocRootCertificatesAll = (
1046+
query?: {
1047+
"pagination.key"?: string;
1048+
"pagination.offset"?: string;
1049+
"pagination.limit"?: string;
1050+
"pagination.count_total"?: boolean;
1051+
"pagination.reverse"?: boolean;
1052+
},
1053+
params: RequestParams = {},
1054+
) =>
1055+
this.request<PkiQueryAllRevokedNocRootCertificatesResponse, RpcStatus>({
1056+
path: `/dcl/pki/revoked-noc-root-certificates`,
1057+
method: "GET",
1058+
query: query,
1059+
format: "json",
1060+
...params,
1061+
});
1062+
1063+
/**
1064+
* No description
1065+
*
1066+
* @tags Query
1067+
* @name QueryRevokedNocRootCertificates
1068+
* @summary Queries a RevokedNocRootCertificates by index.
1069+
* @request GET:/dcl/pki/revoked-noc-root-certificates/{subject}/{subjectKeyId}
1070+
*/
1071+
queryRevokedNocRootCertificates = (subject: string, subjectKeyId: string, params: RequestParams = {}) =>
1072+
this.request<PkiQueryGetRevokedNocRootCertificatesResponse, RpcStatus>({
1073+
path: `/dcl/pki/revoked-noc-root-certificates/${subject}/${subjectKeyId}`,
1074+
method: "GET",
1075+
format: "json",
1076+
...params,
1077+
});
1078+
10111079
/**
10121080
* No description
10131081
*

0 commit comments

Comments
 (0)