Skip to content

Commit

Permalink
chore: Remove unused dmPublicKey
Browse files Browse the repository at this point in the history
  • Loading branch information
Lucas Leblow committed Apr 8, 2024
1 parent c35ec3c commit 715bd16
Show file tree
Hide file tree
Showing 29 changed files with 8 additions and 126 deletions.
1 change: 0 additions & 1 deletion packages/backend/src/nest/common/client-server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ export const createUsersCerts = async (
nickname: 'dev99damian1',
commonName: onion,
peerId: 'Qmf3ySkYqLET9xtAtDzvAr5Pp3egK1H3C5iJAZm1SpLert',
dmPublicKey: 'dmPublicKey1',
signAlg: configCrypto.signAlg,
hashAlg: configCrypto.hashAlg,
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@ describe('RegistrationService', () => {
nickname: 'userName',
commonName: 'nqnw4kc4c77fb47lk52m5l57h4tcxceo7ymxekfn7yh5m66t4jv2olad.onion',
peerId: 'Qmf3ySkYqLET9xtAtDzvAr5Pp3egK1H3C5iJAZm1SpLEp6',
dmPublicKey: 'testdmPublicKey',
signAlg: configCrypto.signAlg,
hashAlg: configCrypto.hashAlg,
})
Expand Down Expand Up @@ -88,7 +87,6 @@ describe('RegistrationService', () => {
nickname: 'alice',
commonName: 'nqnw4kc4c77fb47lk52m5l57h4tcxceo7ymxekfn7yh5m66t4jv2olad.onion',
peerId: 'Qmf3ySkYqLET9xtAtDzvAr5Pp3egK1H3C5iJAZm1SpLEp6',
dmPublicKey: 'testdmPublicKey',
signAlg: configCrypto.signAlg,
hashAlg: configCrypto.hashAlg,
})
Expand Down Expand Up @@ -122,7 +120,6 @@ describe('RegistrationService', () => {
nickname: 'userName2',
commonName: 'nqnw4kc4c77fb47lk52m5l57h4tcxceo7ymxekfn7yh5m66t4jv2olad.onion',
peerId: 'Qmf3ySkYqLET9xtAtDzvAr5Pp3egK1H3C5iJAZm1SpLEp6',
dmPublicKey: 'testdmPublicKey',
signAlg: configCrypto.signAlg,
hashAlg: configCrypto.hashAlg,
})
Expand All @@ -136,15 +133,13 @@ describe('RegistrationService', () => {
nickname: 'karol',
commonName: 'nqnw4kc4c77fb47lk52m5l57h4tcxceo7ymxekfn7yh5m66t4jv2olad.onion',
peerId: 'Qmf3ySkYqLET9xtAtDzvAr5Pp3egK1H3C5iJAZm1SpLEp6',
dmPublicKey: 'testdmPublicKey',
signAlg: configCrypto.signAlg,
hashAlg: configCrypto.hashAlg,
})
const userCsr2 = await createUserCsr({
nickname: 'karol',
commonName: 'nnnnnnc4c77fb47lk52m5l57h4tcxceo7ymxekfn7yh5m66t4jv2olad.onion',
peerId: 'QmffffffqLET9xtAtDzvAr5Pp3egK1H3C5iJAZm1SpLEp6',
dmPublicKey: 'testdmPublicKey',
signAlg: configCrypto.signAlg,
hashAlg: configCrypto.hashAlg,
})
Expand Down Expand Up @@ -187,7 +182,6 @@ describe('RegistrationService', () => {
nickname: 'alice',
commonName: 'nqnw4kc4c77fb47lk52m5l57h4tcxceo7ymxekfn7yh5m66t4jv2olad.onion',
peerId: 'Qmf3ySkYqLET9xtAtDzvAr5Pp3egK1H3C5iJAZm1SpLEp6',
dmPublicKey: 'testdmPublicKey',
signAlg: configCrypto.signAlg,
hashAlg: configCrypto.hashAlg,
})
Expand All @@ -196,7 +190,6 @@ describe('RegistrationService', () => {
nickname: 'alice',
commonName: 'nnnnnnc4c77fb47lk52m5l57h4tcxceo7ymxekfn7yh5m66t4jv2olad.onion',
peerId: 'QmffffffqLET9xtAtDzvAr5Pp3egK1H3C5iJAZm1SpLEp6',
dmPublicKey: 'testdmPublicKey',
signAlg: configCrypto.signAlg,
hashAlg: configCrypto.hashAlg,
})
Expand Down
4 changes: 0 additions & 4 deletions packages/backend/src/nest/storage/storage.service.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -525,15 +525,11 @@ describe('StorageService', () => {
{
onionAddress: '6vu2bxki777it3cpayv6fq6vpl4ke3kzj7gxicfygm55dhhtphyfdvyd.onion',
peerId: 'QmXRY4rhAx8Muq8dMGkr9qknJdE6UHZDdGaDRTQEbwFN5b',
dmPublicKey:
'299abdb3a1c456245fa65560624ba583a5d5e35d5945ee14d548df5d37f5a516b281f71e9c66d3e9145a80fb59ce3baae611dd621a838d1cd98676e7f1901261380133ba9cb1e52ae54a52d69134f032368de3caa9ab69dcfce6e9afcc192ce21129d1131efce0994a7f028c8c9977dd403c9509bd9e149e0081f2071ddce0b7fc217756da7deb9e16d57e3a41300c7087a96df9ee5a82d197cbeabfc4011251e2cf7d481161672d94b82df0ea7e593a4bc81919b1516806f26b32dd9774cd11237d98cd346be7a19715ae15c90998e715f095048f8227403fb8cf915ca035ca1e5ef033d990a4dc84750a7de65fc9cc928e773250cd68c625754400d2e836f3f4bb0654a56aad820c3e0e977b304eaec2e0a193c4aac8dfaaee614671ecd11a40317957b56fa8f099d1f6684c826e4984d0ebb8',
username: 'o',
},
{
onionAddress: 'y7yczmugl2tekami7sbdz5pfaemvx7bahwthrdvcbzw5vex2crsr26qd.onion',
peerId: 'QmT18UvnUBkseMc3SqnfPxpHwN8nzLrJeNSLZtc8rAFXhz',
dmPublicKey:
'050bf2be48a25c47ff3cb2a7b11d416bd02162c54ef28e7a6e77ed527a15cc19516605332c9bce4aba0f93f1266d5cfea2484cadc60d802587bf1ac0a87555ab42513fa6e2f7c06d094a2dc7a38f147a792b94022fad21a1dd6e02784aa1cc891bdb6ca0cf5a4be92b9ff93e83844206388f676e5c0bb406fd436beb0c8843c7a5061a3830a9bc88ea7b112852b19395d5feb1ae75d8082ff3c9473ce4612ec9c2f35489a0010bcf0136dd333638cd21a734b1f192f494371691f4b9c459ffa2d637aa70e8973af99dc94e417b766a8462afbc183fe6fc8b4220887de6a98d97a69cba851d0062b609439b6c6728be87cccc9f6680073d5ed8716611e2ca54f49bbc43c6aa49e02bcb1eecc79e5e491e063b95104e8e43ad09fac6d930399ff2b6c3a49c5b6117c8dc03db9300c0ca0364f29425',
username: 'o',
},
])
Expand Down
5 changes: 2 additions & 3 deletions packages/backend/src/nest/storage/storage.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -738,9 +738,8 @@ export class StorageService extends EventEmitter {
const onionAddress = getReqFieldValue(parsedCert, CertFieldsTypes.commonName)
const peerId = getReqFieldValue(parsedCert, CertFieldsTypes.peerId)
const username = getReqFieldValue(parsedCert, CertFieldsTypes.nickName)
const dmPublicKey = getReqFieldValue(parsedCert, CertFieldsTypes.dmPublicKey)
if (!onionAddress || !peerId || !username || !dmPublicKey) continue
allUsers.push({ onionAddress, peerId, username, dmPublicKey })
if (!onionAddress || !peerId || !username) continue
allUsers.push({ onionAddress, peerId, username })
}
return allUsers
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,10 +66,6 @@ const Template: ComponentStory<typeof ChannelComponent> = () => {
privKey: 'privKey',
pubKey: 'pubKey',
},
dmKeys: {
publicKey: 'publicKey',
privateKey: 'privateKey',
},
userCsr: {
userCsr: 'userCsr',
userKey: 'userKey',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,6 @@ const args: Partial<ChannelComponentProps & UploadFilesPreviewsProps> = {
privKey: 'privKey',
pubKey: 'pubKey',
},
dmKeys: {
publicKey: 'publicKey',
privateKey: 'privateKey',
},
userCsr: {
userCsr: 'userCsr',
userKey: 'userKey',
Expand Down
22 changes: 4 additions & 18 deletions packages/identity/src/common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ export enum CertFieldsTypes {
subjectAltName = '2.5.29.17',
nickName = '1.3.6.1.4.1.50715.2.1',
peerId = '1.3.6.1.2.1.15.3.1.1',
dmPublicKey = '1.2.840.113549.1.9.12',
}

export enum ExtensionsTypes {
Expand Down Expand Up @@ -100,17 +99,9 @@ export const getCertFieldValue = (cert: Certificate, fieldType: CertFieldsTypes
} else {
const ext = cert.extensions?.find(tav => tav.extnID === fieldType)
if (ext) {
if (fieldType === CertFieldsTypes.dmPublicKey) {
const extObj = ext?.extnValue.valueBlock.value[0]
// @ts-ignore
const arrayBuffer = extObj.valueBlock.valueHex

return arrayBufferToHexString(arrayBuffer)
} else {
const extObj = ext?.extnValue.valueBlock.value[0]
// @ts-ignore
return extObj.valueBlock.value
}
const extObj = ext?.extnValue.valueBlock.value[0]
// @ts-ignore
return extObj.valueBlock.value
} else {
return null
}
Expand All @@ -131,12 +122,7 @@ export const getReqFieldValue = (
} else {
const ext = csr.attributes?.find(tav => tav.type === fieldType)
if (ext) {
if (fieldType === CertFieldsTypes.dmPublicKey) {
const extObj = ext.values[0].valueBlock.valueHex
return arrayBufferToHexString(extObj)
} else {
return ext.values[0].valueBlock.value
}
return ext.values[0].valueBlock.value
} else {
return null
}
Expand Down
7 changes: 0 additions & 7 deletions packages/identity/src/createUserCert.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,14 +69,12 @@ async function generateUserCertificate({
],
})
const attr: Attribute[] | undefined = pkcs10.attributes
let dmPubKey = null
let nickname = null
let peerId = null
let onionAddress = null
let altNames

try {
dmPubKey = attr?.[1].values[0].valueBlock.valueHex
nickname = attr?.[2].values[0].valueBlock.value
peerId = attr?.[3].values[0].valueBlock.value
onionAddress = attr?.[4].values[0].valueBlock.value
Expand Down Expand Up @@ -114,11 +112,6 @@ async function generateUserCertificate({
extnValue: extKeyUsage.toSchema().toBER(false),
parsedValue: extKeyUsage, // Parsed value for well-known extensions
}),
new Extension({
extnID: CertFieldsTypes.dmPublicKey,
critical: false,
extnValue: new OctetString({ valueHex: dmPubKey }).toBER(false),
}),
new Extension({
extnID: CertFieldsTypes.nickName,
critical: false,
Expand Down
10 changes: 0 additions & 10 deletions packages/identity/src/createUserCsr.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,11 @@ export const createUserCsr = async ({
nickname,
commonName,
peerId,
dmPublicKey,
existingKeyPair,
}: {
nickname: string
commonName: string
peerId: string
dmPublicKey: string
signAlg: string
hashAlg: string
existingKeyPair?: CryptoKeyPair
Expand All @@ -35,7 +33,6 @@ export const createUserCsr = async ({
nickname,
commonName,
peerId,
dmPublicKey,
signAlg: config.signAlg,
hashAlg: config.hashAlg,
existingKeyPair,
Expand All @@ -59,22 +56,19 @@ async function requestCertificate({
nickname,
commonName,
peerId,
dmPublicKey,
signAlg = config.signAlg,
hashAlg = config.hashAlg,
existingKeyPair,
}: {
nickname: string
commonName: string
peerId: string
dmPublicKey: string
signAlg: string
hashAlg: string
existingKeyPair?: CryptoKeyPair
}): Promise<CertData> {
const keyPair: CryptoKeyPair = existingKeyPair ? existingKeyPair : await generateKeyPair({ signAlg })

const arrayBufferDmPubKey = hexStringToArrayBuffer(dmPublicKey)

const pkcs10 = new CertificationRequest({
version: 0,
Expand Down Expand Up @@ -110,10 +104,6 @@ async function requestCertificate({
}).toSchema(),
],
}),
new Attribute({
type: CertFieldsTypes.dmPublicKey,
values: [new OctetString({ valueHex: arrayBufferDmPubKey })],
}),
new Attribute({
type: CertFieldsTypes.nickName,
values: [new PrintableString({ value: nickname })],
Expand Down
3 changes: 0 additions & 3 deletions packages/identity/src/test/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ export const userData = {
nickname: 'userName',
commonName: 'nqnw4kc4c77fb47lk52m5l57h4tcxceo7ymxekfn7yh5m66t4jv2olad.onion',
peerId: 'Qmf3ySkYqLET9xtAtDzvAr5Pp3egK1H3C5iJAZm1SpLEp6',
dmPublicKey: '0bfb475810c0e26c9fab590d47c3d60ec533bb3c451596acc3cd4f21602e9ad9',
signAlg: config.signAlg,
hashAlg: config.hashAlg,
}
Expand Down Expand Up @@ -62,7 +61,6 @@ export const createUserCertificateTestHelper = async (
nickname: string
commonName: string
peerId: string
dmPublicKey: string
},
rootCA?: Pick<RootCA, 'rootCertString' | 'rootKeyString'> | null
): Promise<{
Expand All @@ -73,7 +71,6 @@ export const createUserCertificateTestHelper = async (
nickname: user.nickname,
commonName: user.commonName,
peerId: user.peerId,
dmPublicKey: user.dmPublicKey,
signAlg: config.signAlg,
hashAlg: config.hashAlg,
})
Expand Down
3 changes: 0 additions & 3 deletions packages/identity/src/test/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,6 @@ describe('Certificate', () => {
[CertFieldsTypes.commonName]: userData.commonName,
[CertFieldsTypes.nickName]: userData.nickname,
[CertFieldsTypes.peerId]: userData.peerId,
[CertFieldsTypes.dmPublicKey]: userData.dmPublicKey,
}
type CertFieldsTypesKeys = keyof typeof certTypeData

Expand All @@ -107,7 +106,6 @@ describe('Certificate', () => {
[CertFieldsTypes.commonName]: userData.commonName,
[CertFieldsTypes.nickName]: userData.nickname,
[CertFieldsTypes.peerId]: userData.peerId,
[CertFieldsTypes.dmPublicKey]: userData.dmPublicKey,
}
type CertFieldsTypesKeys = keyof typeof certTypeData

Expand All @@ -126,7 +124,6 @@ describe('Certificate', () => {
'MIIB7TCCAZMCBgF641h5xzAKBggqhkjOPQQDAjASMRAwDgYDVQQDEwdaYmF5IENBMB4XDTIxMDcyNjE1MDQyNFoXDTMwMDIwMTAwMDAwMFowgc4xgcswHAYKKwYBBAGDjBsCARMOZGV2OTlkZXY5OXlvZGEwPwYDVQQDEzgzNWNzNmZramJoZmJiMnppYnIzNm5rdXY0cWlld2x2NXBmcGprbHh2N2xtcGphM2hydTN3NDdpZDA7BgkrBgECAQ8DAQETLlFtVmIxbUZ2Z1hKZXRKS0o1NmRtR1Q2Rkd1TnJtM0VhVFZ6V3VHaGtxcjZodjUwLQYJKoZIhvcNAQkMBCCf3wijnripB3ZADnDgT1ZIr1zUGjHVZI2K4kt6Yb7CazBZMBMGByqGSM49AgEGCCqGSM49AwEHA0IABDKw/zcoE2Vahw3q9CdRQsCXikFU8PhEIN/y65hrB6yAxWH4Ut9QBKMMAnaG8JlzvEeaScQiu5Jyyx0O0xAadQ+jHTAbMAwGA1UdEwQFMAMCAQMwCwYDVR0PBAQDAgAGMAoGCCqGSM49BAMCA0gAMEUCIQCRz+6W3K3SI7Q7uYDVVIJXnWud/DGvpqHCuLJ+gnJLMgIgBmS1D8s1xnGOQpARx40vus4b/f49LQeG2YxPCSHVQOM='
)

expect(getCertFieldValue(parsedCert, CertFieldsTypes.dmPublicKey)).toEqual(null)
expect(getCertFieldValue(parsedCert, CertFieldsTypes.subjectAltName)).toEqual(null)
expect(getCertFieldValue(parsedCert, CertFieldsTypes.peerId)).toEqual(null)
expect(getCertFieldValue(parsedCert, CertFieldsTypes.nickName)).toEqual(null)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -254,15 +254,11 @@ describe('UsernameRegistration', () => {
currentUsername={'john'}
registeredUsers={{
'BCidRGCBqBPNGNrZ1oml99/qtHjZ6ZtliVzJPpReZk9YC6+aQ1zeooOlpyzv7rNG6nMX2R5ffaVkZZFgEMdNEBg=': {
dmPublicKey:
'1c63a0152f0b0221f96c80aab6777e2569d27a14e991dccd086e34cda1c55d9d6e898efdb9cb5a16d2f90b4155e34abf3261c84e76936ba0105929922feda1fb0615f3254cc56c056cb6144076d0cbdba67cf0fb6687a97d9bb6621bb6b38dcf08aa509f1164212118111f045edc5dab8d315d6e1241cdd10c40883ea420d10d560e48329e086154645035af0668e372a381fbd8aa0912f3581de34b50361cc31adf7a8e811504b6970c9093c058f0fb41ae27df64b09bcb13df84bd23d47a0024463cbb92ee917af3b77b168deb93f6da2d0d13a361969447e16bf249edd872b4797125fa86aad1ce35b1d6ee449359f31c9224a70997d0f0ca38c1f796cede660dd0bb3b1fc9ec251f896bc0aec1603ee8e1278c76d9d1e52adcfa0a06658d631486016efb3b5f44e0c3fb1ce4299834cdf05e',
onionAddress: 'zpu47hphczcuyt3auu5pr2knvimf3adm76gt3g7zbspungjbm3tsy3ad.onion',
peerId: 'QmPrgB2jSFvr7yP3vbLKMLW4JS9hoA9kj2fhN8VjE2NWvJ',
username: 'owner',
},
'BJ50trLih9tvIznBAi69dLNpBV5YiQHCU610UfH3Qm9t3cki9QHWAAhvrfOX+763BH1fwqkOU3JsoBAEF1+USvM=': {
dmPublicKey:
'01161f217d3b372ddefe390b6aed6ada3f21c7ca0d2aacd125840d0c420030b5caec93fbcc1825bb19f38448c1573be814c827b3bce99f6d37b427044687b63799ce0cd7133a654eb2c5644405380399ed0b9140cf0f6d2937008929be8c8ad97cba64e08f7608bb54e0148c8bb30fd2c6df2b8d237cdbfe7ae3d300d896c0ce9e3c5006b687f2e573bedb68152db1954869c21243ef1557eb6d442138ad98e47285f5dd9475fac3a06d2972ae775bdc50d5ab59676d27367c15954b64b0b1a29083ac78934f3f1d0088b73389e29d84f61c60c321770550ecdffa9a24cf0c7fdd279974b5703ce105f22d683530c2f62b36945b3d97f88256f31e1146c3861993a989f5cd99bda647d8744068c3bb44eea407f33109c9c1a0f790f745a6ff2bfd45f5be741fc351549b11d54a4980c4d6d7afb4',
onionAddress: 'lr5d3d64p4hx4mw3uue3ufews23jhl6bfqnsimt7j52igjqdv2zrmsyd.onion',
peerId: 'QmWwMev68izPUKB1PGxkG3UHHXiappQQAnkvUwPSTzrUyy',
username: 'johnny',
Expand Down Expand Up @@ -438,7 +434,7 @@ describe('UsernameRegistration', () => {
verticalTextAlign="center"
>
We’re sorry, but the username
<Text
color="main"
fontSize={14}
Expand Down Expand Up @@ -577,7 +573,7 @@ describe('UsernameRegistration', () => {
}
verticalTextAlign="center"
>
Your username will be public, but you can choose any name you like. No spaces or special characters. Lowercase letters and numbers only.
Your username will be public, but you can choose any name you like. No spaces or special characters. Lowercase letters and numbers only.
</Text>
</View>
<View
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,6 @@ describe('connectionReducer', () => {
username: alice.nickname,
onionAddress: alice.hiddenService.onionAddress,
peerId: alice.peerId.id,
dmPublicKey: alice.dmKeys.publicKey,
isDuplicated: false,
isRegistered: true,
pubKey,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,6 @@ export function* createNetworkSaga(
nickname: '',
hiddenService: network.hiddenService,
peerId: network.peerId,
dmKeys,
userCsr: null,
userCertificate: null,
joinTimestamp: null,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,6 @@ describe('checkLocalCsr', () => {
nickname: 'alice',
commonName: identity.hiddenService.onionAddress,
peerId: identity.peerId.id,
dmPublicKey: identity.dmKeys.publicKey,
signAlg: 'ECDSA',
hashAlg: 'sha-256',
existingKeyPair,
Expand Down
12 changes: 0 additions & 12 deletions packages/state-manager/src/sagas/identity/identity.types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,6 @@ export interface UserCsr {
pkcs10: CertData
}

export interface CreateDmKeyPairPayload {
dmPublicKey: string
dmPrivateKey: string
}

export interface HiddenService {
onionAddress: string
privateKey: string
Expand All @@ -26,16 +21,10 @@ export interface PeerId {
privKey?: string
}

export interface DmKeys {
publicKey: string
privateKey: string
}

export interface Identity {
id: string
nickname: string
hiddenService: HiddenService
dmKeys: DmKeys
peerId: PeerId
userCsr: UserCsr | null
userCertificate: string | null
Expand All @@ -46,7 +35,6 @@ export interface CreateUserCsrPayload {
nickname: string
commonName: string
peerId: string
dmPublicKey: string
signAlg: string
hashAlg: string
}
Expand Down
Loading

0 comments on commit 715bd16

Please sign in to comment.