@ibgib/core-gib 0.0.53 → 0.0.54
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/dist/common/encrypt/encrypt-helper.d.mts.map +1 -1
- package/dist/common/encrypt/encrypt-helper.mjs +27 -27
- package/dist/common/encrypt/encrypt-helper.mjs.map +1 -1
- package/dist/common/encrypt/encrypt-types.d.mts +4 -4
- package/dist/common/encrypt/encrypt-types.d.mts.map +1 -1
- package/dist/common/encrypt/encrypt-types.mjs +1 -1
- package/dist/common/encrypt/encrypt-types.mjs.map +1 -1
- package/dist/common/encrypt/encrypt.respec.d.mts +7 -0
- package/dist/common/encrypt/encrypt.respec.d.mts.map +1 -0
- package/dist/common/encrypt/encrypt.respec.mjs +69 -0
- package/dist/common/encrypt/encrypt.respec.mjs.map +1 -0
- package/dist/common/secret/secret-helper.d.mts.map +1 -1
- package/dist/common/secret/secret-helper.mjs.map +1 -1
- package/dist/witness/space/metaspace/metaspace-base.d.mts.map +1 -1
- package/dist/witness/space/metaspace/metaspace-base.mjs +2 -1
- package/dist/witness/space/metaspace/metaspace-base.mjs.map +1 -1
- package/package.json +1 -1
- package/src/common/encrypt/encrypt-helper.mts +24 -25
- package/src/common/encrypt/encrypt-types.mts +3 -3
- package/src/common/encrypt/encrypt.respec.mts +90 -0
- package/src/common/secret/secret-helper.mts +1 -3
- package/src/witness/space/metaspace/metaspace-base.mts +2 -1
|
@@ -7,7 +7,7 @@ import { ENCRYPTION_REL8N_NAME } from './encrypt-constants.mjs';
|
|
|
7
7
|
|
|
8
8
|
|
|
9
9
|
|
|
10
|
-
export type EncryptionMethod = 'encrypt-gib
|
|
10
|
+
export type EncryptionMethod = 'encrypt-gib';
|
|
11
11
|
/**
|
|
12
12
|
* Discriminator for the algorithm used in encryption that specifies the
|
|
13
13
|
* algorithm used in encryption.
|
|
@@ -20,7 +20,7 @@ export const EncryptionMethod = {
|
|
|
20
20
|
* custom probably very weak algorithm that uses indexing into a recursive
|
|
21
21
|
* hash-based rounding function instead of keystream generation.
|
|
22
22
|
*/
|
|
23
|
-
|
|
23
|
+
encrypt_gib: 'encrypt-gib' as EncryptionMethod,
|
|
24
24
|
}
|
|
25
25
|
export const VALID_ENCRYPTION_METHODS = Object.values(EncryptionMethod);
|
|
26
26
|
|
|
@@ -41,7 +41,7 @@ export interface EncryptionInfo {
|
|
|
41
41
|
* Parameter information that is specific to the encrypt-gib algorithm.
|
|
42
42
|
*/
|
|
43
43
|
export interface EncryptionInfo_EncryptGib extends EncryptionInfo {
|
|
44
|
-
method: 'encrypt-gib
|
|
44
|
+
method: 'encrypt-gib'
|
|
45
45
|
/**
|
|
46
46
|
* This is the algorithm that encrypt-gib will use in its
|
|
47
47
|
* internal hashing round function to encrypt the data.
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @module encryption respec
|
|
3
|
+
*
|
|
4
|
+
* we gotta test our encryption ibgibs
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
// import { cwd, chdir, } from 'node:process';
|
|
8
|
+
// import { statSync } from 'node:fs';
|
|
9
|
+
// import { mkdir, } from 'node:fs/promises';
|
|
10
|
+
// import { ChildProcess, exec, ExecException } from 'node:child_process';
|
|
11
|
+
import * as pathUtils from 'path';
|
|
12
|
+
|
|
13
|
+
import {
|
|
14
|
+
firstOfAll, firstOfEach, ifWe, ifWeMight, iReckon,
|
|
15
|
+
lastOfAll, lastOfEach, respecfully, respecfullyDear
|
|
16
|
+
} from '@ibgib/helper-gib/dist/respec-gib/respec-gib.mjs';
|
|
17
|
+
const maam = `[${import.meta.url}]`, sir = maam;
|
|
18
|
+
|
|
19
|
+
import {
|
|
20
|
+
extractErrorMsg, delay, getSaferSubstring,
|
|
21
|
+
getTimestampInTicks, getUUID, pretty, HashAlgorithm, clone, getTimestamp,
|
|
22
|
+
} from '@ibgib/helper-gib/dist/helpers/utils-helper.mjs';
|
|
23
|
+
|
|
24
|
+
import { GLOBAL_LOG_A_LOT } from '../../core-constants.mjs';
|
|
25
|
+
import { EncryptionData_V1, EncryptionMethod } from './encrypt-types.mjs';
|
|
26
|
+
import { SaltStrategy } from '@ibgib/encrypt-gib/dist/types.mjs';
|
|
27
|
+
import { getEncryptionIb, parseEncryptionIb } from './encrypt-helper.mjs';
|
|
28
|
+
import { ENCRYPTION_ATOM } from './encrypt-constants.mjs';
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* for verbose logging
|
|
32
|
+
*/
|
|
33
|
+
const logalot = GLOBAL_LOG_A_LOT; // change this when you want to turn off verbose logging
|
|
34
|
+
|
|
35
|
+
const lcFile: string = `[${pathUtils.basename(import.meta.url)}]`;
|
|
36
|
+
|
|
37
|
+
const atom = ENCRYPTION_ATOM;
|
|
38
|
+
const recursionCount = 168;
|
|
39
|
+
const hashAlgorithm: HashAlgorithm = 'SHA-256';
|
|
40
|
+
const saltPrependedPerHash = '';
|
|
41
|
+
const saltStrategy = SaltStrategy.prependPerHash;
|
|
42
|
+
const initialRecursions = 1000;
|
|
43
|
+
const recursionsPerHash = 2;
|
|
44
|
+
const method: EncryptionMethod = EncryptionMethod.encrypt_gib;
|
|
45
|
+
|
|
46
|
+
const salt_empty = ''; //
|
|
47
|
+
const description = 'description yo';
|
|
48
|
+
|
|
49
|
+
const blockName = `encryption ib`;
|
|
50
|
+
await respecfully(maam, blockName, async () => {
|
|
51
|
+
const lc = `${lcFile}[${blockName}]`;
|
|
52
|
+
debugger;
|
|
53
|
+
|
|
54
|
+
const name = await getUUID();
|
|
55
|
+
const timestampDate = new Date();
|
|
56
|
+
const timestamp = getTimestamp(timestampDate);
|
|
57
|
+
const timestampMs = timestampDate.getMilliseconds().toString();
|
|
58
|
+
|
|
59
|
+
|
|
60
|
+
const data_valid: EncryptionData_V1 = {
|
|
61
|
+
name,
|
|
62
|
+
hashAlgorithm,
|
|
63
|
+
initialRecursions: 1000,
|
|
64
|
+
method,
|
|
65
|
+
salt: salt_empty,
|
|
66
|
+
description,
|
|
67
|
+
encryptedDataDelimiter: undefined,
|
|
68
|
+
recursionsPerHash,
|
|
69
|
+
saltStrategy,
|
|
70
|
+
n: 0, timestamp, timestampMs,
|
|
71
|
+
};
|
|
72
|
+
|
|
73
|
+
|
|
74
|
+
await ifWe(maam, `getEncryptionIb`, async () => {
|
|
75
|
+
const data = data_valid;
|
|
76
|
+
let ib = getEncryptionIb({ data });
|
|
77
|
+
iReckon(sir, ib.includes(name)).asTo('name').isGonnaBeTrue();
|
|
78
|
+
iReckon(sir, ib.includes(method)).asTo('method').isGonnaBeTrue();
|
|
79
|
+
});
|
|
80
|
+
await ifWe(maam, `parseEncryptionIb`, async () => {
|
|
81
|
+
const data = data_valid;
|
|
82
|
+
let ib = getEncryptionIb({ data });
|
|
83
|
+
let parsed = parseEncryptionIb({ ib });
|
|
84
|
+
|
|
85
|
+
iReckon(sir, parsed.atom).asTo('atom').isGonnaBe(atom);
|
|
86
|
+
iReckon(sir, parsed.name).asTo('name').isGonnaBe(name);
|
|
87
|
+
iReckon(sir, parsed.method).asTo('method').isGonnaBe(method);
|
|
88
|
+
});
|
|
89
|
+
|
|
90
|
+
});
|
|
@@ -15,8 +15,7 @@ import {
|
|
|
15
15
|
extractErrorMsg, delay, getSaferSubstring,
|
|
16
16
|
getTimestampInTicks, getUUID, pretty, HashAlgorithm, getTimestamp,
|
|
17
17
|
} from '@ibgib/helper-gib/dist/helpers/utils-helper.mjs';
|
|
18
|
-
import {
|
|
19
|
-
import { UUID_REGEXP, CLASSNAME_REGEXP, } from '@ibgib/helper-gib/dist/constants.mjs';
|
|
18
|
+
import { CLASSNAME_REGEXP, } from '@ibgib/helper-gib/dist/constants.mjs';
|
|
20
19
|
import { Ib, } from '@ibgib/ts-gib/dist/types.mjs';
|
|
21
20
|
import { validateIbGibIntrinsically } from '@ibgib/ts-gib/dist/V1/validate-helper.mjs';
|
|
22
21
|
import { Factory_V1 } from "@ibgib/ts-gib/dist/V1/factory.mjs";
|
|
@@ -26,7 +25,6 @@ import { CheckIfPasswordProbablyCorrectInfo, SecretData_V1, SecretIbGib_V1, Secr
|
|
|
26
25
|
import { SECRET_ATOM, SECRET_NAME_REGEXP, SECRET_REL8N_NAME, } from './secret-constants.mjs';
|
|
27
26
|
import { MetaspaceService } from "../../witness/space/metaspace/metaspace-types.mjs";
|
|
28
27
|
import { IbGibSpaceAny } from "../../witness/space/space-base-v1.mjs";
|
|
29
|
-
import { SpecialIbGibType } from "../other/other-types.mjs";
|
|
30
28
|
import { INVALID_DATE_STRING } from '../other/other-constants.mjs';
|
|
31
29
|
import { hash16816 } from '../other/ibgib-helper.mjs';
|
|
32
30
|
|
|
@@ -25,6 +25,7 @@ import { RootData } from '../../../common/root/root-types.mjs';
|
|
|
25
25
|
import {
|
|
26
26
|
CiphertextData, CiphertextIbGib_V1, CiphertextRel8ns,
|
|
27
27
|
EncryptionData_V1, EncryptionIbGib_V1, EncryptionInfo_EncryptGib,
|
|
28
|
+
EncryptionMethod,
|
|
28
29
|
} from '../../../common/encrypt/encrypt-types.mjs';
|
|
29
30
|
import { RobbotIbGib_V1 } from '../../../witness/robbot/robbot-types.mjs';
|
|
30
31
|
import { AppIbGib_V1 } from '../../../witness/app/app-types.mjs';
|
|
@@ -1796,7 +1797,7 @@ export abstract class MetaspaceBase implements MetaspaceService {
|
|
|
1796
1797
|
const lc = `${this.lc}[${this.getCiphertextIbGib.name}]`;
|
|
1797
1798
|
try {
|
|
1798
1799
|
const encryptionInfo = encryptionIbGib.data;
|
|
1799
|
-
if (encryptionInfo?.method !==
|
|
1800
|
+
if (encryptionInfo?.method !== EncryptionMethod.encrypt_gib) {
|
|
1800
1801
|
throw new Error('only encrypt-gib is implemented.');
|
|
1801
1802
|
}
|
|
1802
1803
|
const info: EncryptionInfo_EncryptGib = encryptionInfo;
|