Skip to content

Commit 8e74070

Browse files
committedSep 4, 2017
refactoring Player.java out (embeeded inside QuorumContext)
1 parent b4c6efa commit 8e74070

File tree

4 files changed

+25
-41
lines changed

4 files changed

+25
-41
lines changed
 

‎MPCApplet/src/mpc/MPCApplet.java

+3-18
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@ public class MPCApplet extends Applet {
2424
// TODO: Enable/disable propagation of private key to other quorum
2525
// TODO: Generate unique card key for signatures
2626
// TODO: Make unified structure of input data Sign(QuorumContextIndex | command apdu)_CardKey
27+
// TODO: unify response codes
2728

28-
Bignat Sign_counter = null; // TODO: move into shared temp values
2929
QuorumContext[] m_quorums = null;
3030

3131
public byte[] cardIDLong = null; // unique card ID generated during applet install
@@ -46,10 +46,6 @@ public MPCApplet() {
4646
m_quorums[i] = new QuorumContext(m_ecc, m_curve, m_cryptoOps);
4747
}
4848

49-
Sign_counter = new Bignat((short) 2, JCSystem.MEMORY_TYPE_TRANSIENT_RESET, m_ecc.bnh);
50-
51-
52-
5349
/*// Signing - older protocol with explicit hash
5450
CryptoObjects.EphimeralKey = new DKG();
5551
CryptoObjects.EphimeralKey_next = new DKG();
@@ -665,9 +661,9 @@ void Sign(APDU apdu) {
665661
// TODO: Check authorization to ask for signs
666662
// TODO: Check for strictly increasing request counter
667663

668-
Sign_counter.from_byte_array((short) 2, (short) 0, m_cryptoOps.shortToByteArray((short) (apdubuf[ISO7816.OFFSET_P1] & 0xff)), (short) 0);
664+
m_cryptoOps.temp_sign_counter.from_byte_array((short) 2, (short) 0, m_cryptoOps.shortToByteArray((short) (apdubuf[ISO7816.OFFSET_P1] & 0xff)), (short) 0);
669665

670-
dataLen = m_cryptoOps.Sign(m_quorums[0], Sign_counter, apdubuf, (short) (ISO7816.OFFSET_CDATA), dataLen, apdubuf, (short) 0, apdubuf[ISO7816.OFFSET_P2]);
666+
dataLen = m_cryptoOps.Sign(m_quorums[0], m_cryptoOps.temp_sign_counter, apdubuf, (short) (ISO7816.OFFSET_CDATA), dataLen, apdubuf, (short) 0, apdubuf[ISO7816.OFFSET_P2]);
671667
apdu.setOutgoingAndSend((short) 0, dataLen); //Send signature share
672668
}
673669

@@ -706,17 +702,6 @@ void GenerateRandomData(APDU apdu) {
706702
apdu.setOutgoingAndSend((short) 0, len);
707703
}
708704

709-
710-
public final static byte[] xe_Bn_testInput1 = {
711-
(byte) 0x03, (byte) 0xBD, (byte) 0x28, (byte) 0x6B, (byte) 0x6A, (byte) 0x22, (byte) 0x1F, (byte) 0x1B,
712-
(byte) 0xFC, (byte) 0x08, (byte) 0xC6, (byte) 0xC5, (byte) 0xB0, (byte) 0x3F, (byte) 0x0B, (byte) 0xEA,
713-
(byte) 0x6C, (byte) 0x38, (byte) 0xBE, (byte) 0xBA, (byte) 0xCF, (byte) 0x20, (byte) 0x2A, (byte) 0xAA,
714-
(byte) 0xDF, (byte) 0xAC, (byte) 0xA3, (byte) 0x70, (byte) 0x38, (byte) 0x32, (byte) 0xF8, (byte) 0xCC,
715-
(byte) 0xE0, (byte) 0xA8, (byte) 0x70, (byte) 0x88, (byte) 0xE9, (byte) 0x17, (byte) 0x21, (byte) 0xA3,
716-
(byte) 0x4C, (byte) 0x8D, (byte) 0x0B, (byte) 0x97, (byte) 0x11, (byte) 0x98, (byte) 0x02, (byte) 0x46,
717-
(byte) 0x04, (byte) 0x56, (byte) 0x40, (byte) 0xA1, (byte) 0xAE, (byte) 0x34, (byte) 0xC1, (byte) 0xFB,
718-
(byte) 0x7D, (byte) 0xB8, (byte) 0x45, (byte) 0x28, (byte) 0xC6, (byte) 0x1B, (byte) 0xC6, (byte) 0xD0};
719-
720705
void TestNativeECC(APDU apdu, short dataLen) {
721706
/*
722707
byte[] buff = apdu.getBuffer();

‎MPCApplet/src/mpc/MPCCryptoOperations.java

+16-1
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@
1616
public class MPCCryptoOperations {
1717
RandomData randomData = null;
1818
MessageDigest md = null;
19+
20+
Bignat temp_sign_counter = null;
1921

2022
ECPointBase placeholder = null;
2123
ECPointBase c2_EC = null;
@@ -96,6 +98,8 @@ public class MPCCryptoOperations {
9698
(byte) 0xAB, (byte) 0x0D, (byte) 0xBA, (byte) 0xA1, (byte) 0x5A, (byte) 0x16, (byte) 0x83, (byte) 0xA1};
9799

98100
public MPCCryptoOperations(ECConfig eccfg) {
101+
temp_sign_counter = new Bignat((short) 2, JCSystem.MEMORY_TYPE_TRANSIENT_RESET, eccfg.bnh);
102+
99103
placeholder = ECPointBuilder.createPoint(SecP256r1.KEY_LENGTH);
100104
placeholder.initializeECPoint_SecP256r1();
101105

@@ -234,7 +238,18 @@ static short sendBignat(Bignat value, byte[] outputArray, short outputBaseOffset
234238
return (short) (outOffset - outputBaseOffset);
235239
}
236240

237-
241+
/*
242+
public final static byte[] xe_Bn_testInput1 = {
243+
(byte) 0x03, (byte) 0xBD, (byte) 0x28, (byte) 0x6B, (byte) 0x6A, (byte) 0x22, (byte) 0x1F, (byte) 0x1B,
244+
(byte) 0xFC, (byte) 0x08, (byte) 0xC6, (byte) 0xC5, (byte) 0xB0, (byte) 0x3F, (byte) 0x0B, (byte) 0xEA,
245+
(byte) 0x6C, (byte) 0x38, (byte) 0xBE, (byte) 0xBA, (byte) 0xCF, (byte) 0x20, (byte) 0x2A, (byte) 0xAA,
246+
(byte) 0xDF, (byte) 0xAC, (byte) 0xA3, (byte) 0x70, (byte) 0x38, (byte) 0x32, (byte) 0xF8, (byte) 0xCC,
247+
(byte) 0xE0, (byte) 0xA8, (byte) 0x70, (byte) 0x88, (byte) 0xE9, (byte) 0x17, (byte) 0x21, (byte) 0xA3,
248+
(byte) 0x4C, (byte) 0x8D, (byte) 0x0B, (byte) 0x97, (byte) 0x11, (byte) 0x98, (byte) 0x02, (byte) 0x46,
249+
(byte) 0x04, (byte) 0x56, (byte) 0x40, (byte) 0xA1, (byte) 0xAE, (byte) 0x34, (byte) 0xC1, (byte) 0xFB,
250+
(byte) 0x7D, (byte) 0xB8, (byte) 0x45, (byte) 0x28, (byte) 0xC6, (byte) 0x1B, (byte) 0xC6, (byte) 0xD0};
251+
*/
252+
238253
public short Sign(QuorumContext quorumCtx, Bignat i, byte[] Rn_plaintext_arr, short plaintextOffset, short plaintextLength, byte[] outputArray, short outputBaseOffset, short perfStop) {
239254

240255
if (perfStop == (short) 1) {ISOException.throwIt((short) (Consts.PERF_SIGN + perfStop));} //153ms

‎MPCApplet/src/mpc/Player.java

-22
This file was deleted.

‎MPCApplet/src/mpc/QuorumContext.java

+6
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,12 @@ public class QuorumContext {
1616

1717
public short CARD_INDEX_THIS = 0; // index of player realised by this card
1818
public short NUM_PLAYERS = 0; // current number of players
19+
20+
class Player {
21+
public byte[] hash = null; // Hash of player's input (commitment)
22+
public boolean bHashValid = false; // Is hash currently valid?
23+
public boolean bYsValid = false; // Is player's share (Ys) currently valid?
24+
}
1925
private Player[] players = null; // contexts for all players (including this card)
2026

2127
public boolean SETUP = false; // Have the scheme parameters been set?

0 commit comments

Comments
 (0)
Please sign in to comment.