-
Notifications
You must be signed in to change notification settings - Fork 145
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: Add placeholder
HintsService
, HistoryService
, integrate wi…
…th app infrastructure (#17222) Signed-off-by: Michael Tinker <michael.tinker@swirldslabs.com> Co-authored-by: Neeharika Sompalli <52669918+Neeharika-Sompalli@users.noreply.github.com>
- Loading branch information
1 parent
46446f1
commit 418e6d3
Showing
45 changed files
with
2,424 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
136 changes: 136 additions & 0 deletions
136
hedera-node/hedera-app/src/main/java/com/hedera/node/app/hints/HintsLibrary.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,136 @@ | ||
/* | ||
* Copyright (C) 2024-2025 Hedera Hashgraph, LLC | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package com.hedera.node.app.hints; | ||
|
||
import com.hedera.node.app.hints.impl.HintsLibraryCodec; | ||
import com.hedera.pbj.runtime.io.buffer.Bytes; | ||
import edu.umd.cs.findbugs.annotations.NonNull; | ||
import java.util.Map; | ||
|
||
/** | ||
* The cryptographic operations required by the {@link HintsService}. The relationship between the hinTS algorithms | ||
* and these operations are as follows: | ||
* <ul> | ||
* <li><b>Key generation</b> ({@code KGen}) - Implemented by {@link HintsLibrary#newBlsKeyPair()}.</li> | ||
* <li><b>Hint generation</b> ({@code HintGen}) - Implemented by {@link HintsLibrary#computeHints(Bytes, int, int)}.</li> | ||
* <li><b>Preprocessing</b> ({@code Preprocess}) - Implemented by using {@link HintsLibrary#preprocess(Map, Map, int)} | ||
* to select the hinTS keys to use as input to {@link HintsLibrary#preprocess(Map, Map, int)}.</li> | ||
* <li><b>Partial signatures</b> ({@code Sign}) - Implemented by {@link HintsLibrary#signBls(Bytes, Bytes)}.</li> | ||
* <li><b>Verifying partial signatures</b> ({@code PartialVerify}) - Implemented by using | ||
* {@link HintsLibrary#verifyBls(Bytes, Bytes, Bytes)} with public keys extracted from the | ||
* aggregation key in the active hinTS scheme via {@link HintsLibraryCodec#extractPublicKey(Bytes, int)}.</li> | ||
* <li><b>Signature aggregation</b> ({@code SignAggr}) - Implemented by {@link HintsLibrary#aggregateSignatures(Bytes, Bytes, Map)} | ||
* with partial signatures verified as above with weights extracted from the aggregation key in the active hinTS | ||
* scheme via {@link HintsLibraryCodec#extractWeight(Bytes, int)} and {@link HintsLibraryCodec#extractTotalWeight(Bytes)}.</li> | ||
* <li><b>Verifying aggregate signatures</b> ({@code Verify}) - Implemented by | ||
* {@link HintsLibrary#verifyAggregate(Bytes, Bytes, Bytes, long, long)}.</li> | ||
* </ul> | ||
*/ | ||
public interface HintsLibrary { | ||
/** | ||
* Generates a new BLS key pair. | ||
* @return the key pair | ||
*/ | ||
Bytes newBlsKeyPair(); | ||
|
||
/** | ||
* Computes the hints for the given public key and number of parties. | ||
* | ||
* @param blsPrivateKey the private key | ||
* @param partyId the party id | ||
* @param n the number of parties | ||
* @return the hints | ||
*/ | ||
Bytes computeHints(@NonNull Bytes blsPrivateKey, int partyId, int n); | ||
|
||
/** | ||
* Validates the hinTS public key for the given number of parties. | ||
* | ||
* @param hintsKey the hinTS key | ||
* @param partyId the party id | ||
* @param n the number of parties | ||
* @return true if the hints are valid; false otherwise | ||
*/ | ||
boolean validateHintsKey(@NonNull Bytes hintsKey, int partyId, int n); | ||
|
||
/** | ||
* Runs the hinTS preprocessing algorithm on the given validated hint keys and party weights for the given number | ||
* of parties. The output includes, | ||
* <ol> | ||
* <li>The linear size aggregation key to use in combining partial signatures on a message with a provably | ||
* well-formed aggregate public key.</li> | ||
* <li>The succinct verification key to use when verifying an aggregate signature.</li> | ||
* </ol> | ||
* Both maps given must have the same key set; in particular, a subset of {@code [0, n)}. | ||
* @param hintsKeys the valid hinTS keys by party id | ||
* @param weights the weights by party id | ||
* @param n the number of parties | ||
* @return the preprocessed keys | ||
*/ | ||
Bytes preprocess(@NonNull Map<Integer, Bytes> hintsKeys, @NonNull Map<Integer, Long> weights, int n); | ||
|
||
/** | ||
* Signs a message with a BLS private key. | ||
* | ||
* @param message the message | ||
* @param privateKey the private key | ||
* @return the signature | ||
*/ | ||
Bytes signBls(@NonNull Bytes message, @NonNull Bytes privateKey); | ||
|
||
/** | ||
* Checks that a signature on a message verifies under a BLS public key. | ||
* | ||
* @param signature the signature | ||
* @param message the message | ||
* @param publicKey the public key | ||
* @return true if the signature is valid; false otherwise | ||
*/ | ||
boolean verifyBls(@NonNull Bytes signature, @NonNull Bytes message, @NonNull Bytes publicKey); | ||
|
||
/** | ||
* Aggregates the signatures for party ids using hinTS aggregation and verification keys. | ||
* | ||
* @param aggregationKey the aggregation key | ||
* @param verificationKey the verification key | ||
* @param partialSignatures the partial signatures by party id | ||
* @return the aggregated signature | ||
*/ | ||
Bytes aggregateSignatures( | ||
@NonNull Bytes aggregationKey, | ||
@NonNull Bytes verificationKey, | ||
@NonNull Map<Integer, Bytes> partialSignatures); | ||
|
||
/** | ||
* Checks an aggregate signature on a message verifies under a hinTS verification key, where | ||
* this is only true if the aggregate signature has weight exceeding the specified threshold | ||
* or total weight stipulated in the verification key. | ||
* | ||
* @param signature the aggregate signature | ||
* @param message the message | ||
* @param verificationKey the verification key | ||
* @param thresholdNumerator the numerator of a fraction of total weight the signature must have | ||
* @param thresholdDenominator the denominator of a fraction of total weight the signature must have | ||
* @return true if the signature is valid; false otherwise | ||
*/ | ||
boolean verifyAggregate( | ||
@NonNull Bytes signature, | ||
@NonNull Bytes message, | ||
@NonNull Bytes verificationKey, | ||
long thresholdNumerator, | ||
long thresholdDenominator); | ||
} |
Oops, something went wrong.