Skip to content

Key generation process is right or wrong? #5

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
Soumya172 opened this issue Feb 12, 2025 · 1 comment
Open

Key generation process is right or wrong? #5

Soumya172 opened this issue Feb 12, 2025 · 1 comment

Comments

@Soumya172
Copy link

When I am generating the public key I am getting only 224 byte non zero value. The rest of values are always zero.
pk: [36, 61, 99, 81, 20, 69, 81, 20, 69, 81, 20, 69, 174, 235, 186, 174, 235, 186, 174, 107, 192, 175, 62, 123, 181, 167, 212, 140, 150, 51, 49, 6, 246, 16, 21, 191, 182, 85, 144, 36, 38, 121, 237, 144, 53, 148, 144, 18, 31, 101, 55, 210, 96, 20, 110, 54, 177, 153, 8, 44, 175, 147, 66, 209, 146, 241, 214, 29, 178, 30, 168, 180, 183, 20, 43, 136, 227, 56, 142, 227, 56, 142, 227, 56, 170, 170, 170, 170, 170, 106, 166, 153, 87, 36, 125, 155, 36, 61, 99, 81, 20, 69, 81, 20, 69, 81, 20, 69, 174, 235, 186, 174, 235, 186, 174, 59, 181, 139, 108, 22, 167, 32, 169, 0, 208, 234, 15, 9, 194, 97, 254, 190, 46, 116, 241, 189, 240, 35, 38, 223, 237, 183, 116, 173, 170, 35, 247, 154, 51, 169, 202, 232, 208, 222, 91, 250, 85, 11, 254, 25, 19, 221, 67, 59, 213, 118, 54, 90, 188, 227, 56, 142, 227, 56, 142, 227, 56, 142, 227, 56, 170, 170, 170, 170, 240, 42, 37, 68, 171, 33, 125, 155, 223, 111, 86, 3, 90, 173, 80, 30, 28, 145, 120, 65, 159, 250, 106, 237, 105, 79, 150, 193, 165, 139, 250, 36, 219, 102, 114, 29, 47, 32, 156, 115, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0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 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]

The issue is that the 'polyveccompress' function is returning an Uint8List of size 192 byte and the public seed of 32 byte is appended to it.

@xscriptorcode
Copy link
Owner

Hi, I'm reviewing it right now because there are some parameters that are below the range to be able to guarantee 64-bit operations, but I'm correcting it, for now, I've modified some and I've made the commit with the test to validate it, as soon as I finish it I'll let you know and I'll close it. Thanks for letting me know... (Now I'm trying to solve the 0...0... situation)

--- IND-CPA Public Key ---
Total Length: 288 bytes

Polyvec Compressed Portion (256 bytes):
Zero count: 65, Non-zero count: 191
Zero ratio: 0.25, Non-zero ratio: 0.75

Polyvec Compressed (hex):
fd ea 9e 50 14 45 51 14 45 51 14 45 ae eb ba ae eb ba ae eb c7 08 57 32 40 48 c0 bd f5 8f 44 65 78 a1 b5 66 86 a5 c6 62 8c 18 4d f6 f6 8f 06 4a ad 01 0f 5d 9d a7 21 06 ed 22 d4 30 dc 7a b1 e8 6d 92 50 d1 27 17 d6 d8 94 65 a8 c3 13 3a 8e e3 38 8e e3 38 aa aa aa aa aa aa aa aa aa c0 ef 32 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 fd ea 9e 50 14 45 51 14 45 51 14 45 ae eb ba ae eb ba ae eb 01 0f 61 6a 69 25 44 b0 52 3d f6 99 1f 14 bb a0 9a 00 16 56 bf a9 0b 9a 63 e4 c7 d7 4c 2c 77 eb c2 d1 2c 3b b7 69 41 c2 ed 94 f2 16 f2 cc 29 15 28 1e 0e 4a a4 39 4c 5c 38 35 53 e8 38 8e e3 38 aa aa aa aa aa aa d4 8b 78 14 e5 b0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00

Polyvec Compressed (decimal list):
[253, 234, 158, 80, 20, 69, 81, 20, 69, 81, 20, 69, 174, 235, 186, 174, 235, 186, 174, 235, 199, 8, 87, 50, 64, 72, 192, 189, 245, 143, 68, 101, 120, 161, 181, 102, 134, 165, 198, 98, 140, 24, 77, 246, 246, 143, 6, 74, 173, 1, 15, 93, 157, 167, 33, 6, 237, 34, 212, 48, 220, 122, 177, 232, 109, 146, 80, 209, 39, 23, 214, 216, 148, 101, 168, 195, 19, 58, 142, 227, 56, 142, 227, 56, 170, 170, 170, 170, 170, 170, 170, 170, 170, 192, 239, 50, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 253, 234, 158, 80, 20, 69, 81, 20, 69, 81, 20, 69, 174, 235, 186, 174, 235, 186, 174, 235, 1, 15, 97, 106, 105, 37, 68, 176, 82, 61, 246, 153, 31, 20, 187, 160, 154, 0, 22, 86, 191, 169, 11, 154, 99, 228, 199, 215, 76, 44, 119, 235, 194, 209, 44, 59, 183, 105, 65, 194, 237, 148, 242, 22, 242, 204, 41, 21, 40, 30, 14, 74, 164, 57, 76, 92, 56, 53, 83, 232, 56, 142, 227, 56, 170, 170, 170, 170, 170, 170, 212, 139, 120, 20, 229, 176, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]

Public Seed (32 bytes, hex):
05 32 54 6a 27 5c 57 32 7a b6 94 a7 b0 5f 73 08 c7 c0 97 f9 2e 8b 1d 55 d5 e9 cc 77 a1 cd e4 23

Full IND-CPA Public Key (Base64):
/eqeUBRFURRFURRFruu6ruu6ruvHCFcyQEjAvfWPRGV4obVmhqXGYowYTfb2jwZKrQEPXZ2nIQbtItQw3Hqx6G2SUNEnF9bYlGWowxM6juM4juM4qqqqqqqqqqqqwO8yAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD96p5QFEVRFEVRFEWu67qu67qu6wEPYWppJUSwUj32mR8Uu6CaABZWv6kLmmPkx9dMLHfrwtEsO7dpQcLtlPIW8swpFSgeDkqkOUxcODVT6DiO4ziqqqqqqqrUi3gU5bAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAUyVGonXFcyeraUp7BfcwjHwJf5LosdVdXpzHehzeQj
✓ IND-CPA Public Key Tests Generated IND-CPA public key has correct size (288 bytes for Kyber512 IND-CPA) and prints content naturally

Exited.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants