|
1 | 1 | package org.tron.common.zksnark.zen.utils; |
2 | 2 |
|
| 3 | +import org.libsodium.jni.NaCl; |
| 4 | +import org.libsodium.jni.Sodium; |
3 | 5 | import org.tron.common.zksnark.zen.Librustzcash; |
4 | | -import org.tron.common.zksnark.zen.Libsodium; |
5 | | -import org.tron.common.zksnark.zen.Libsodium.ILibsodium.crypto_generichash_blake2b_state; |
6 | 6 |
|
7 | 7 | public class PRF { |
8 | 8 |
|
@@ -33,12 +33,17 @@ public static byte[] prfOvk(byte[] sk) { |
33 | 33 | private static byte[] prfExpand(byte[] sk, byte t) { |
34 | 34 | byte[] res = new byte[64]; |
35 | 35 | byte[] blob = new byte[33]; |
36 | | - |
| 36 | + Sodium sodium = NaCl.sodium(); |
37 | 37 | System.arraycopy(sk, 0, blob, 0, 32); |
38 | 38 | blob[32] = t; |
39 | | - crypto_generichash_blake2b_state.ByReference state = new crypto_generichash_blake2b_state.ByReference(); |
40 | | - Libsodium.cryptoGenerichashBlake2bUpdate(state, blob, 33); |
41 | | - Libsodium.cryptoGenerichashBlake2bFinal(state, res, 64); |
| 39 | + |
| 40 | + byte[] state = new byte[Sodium.crypto_generichash_statebytes()]; |
| 41 | + byte[] key = new byte[Sodium.crypto_generichash_keybytes()]; |
| 42 | + |
| 43 | + // Sodium.crypto_generichash_blake2b_init(state, key, 0, 32); |
| 44 | + Sodium.crypto_generichash_blake2b_update(state, blob, 33); |
| 45 | + Sodium.crypto_generichash_blake2b_final(state, res, 64); |
| 46 | + |
42 | 47 | return res; |
43 | 48 | } |
44 | 49 | } |
0 commit comments