Class: MlDsa::BatchBuilder
- Inherits:
-
Object
- Object
- MlDsa::BatchBuilder
- Defined in:
- lib/ml_dsa/batch_builder.rb
Overview
Collects sign or verify operations for batch execution. Obtained via batch. Do not mix sign and verify in one batch.
Instance Method Summary collapse
- #execute(config: MlDsa.config, yield_every: Internal::DEFAULT_YIELD_EVERY) ⇒ Object private
-
#initialize ⇒ BatchBuilder
constructor
A new instance of BatchBuilder.
-
#sign(sk:, message:, context: nil, deterministic: false) ⇒ self
Add a sign operation to the batch.
-
#verify(pk:, message:, signature:, context: nil) ⇒ self
Add a verify operation to the batch.
Constructor Details
#initialize ⇒ BatchBuilder
Returns a new instance of BatchBuilder.
7 8 9 10 |
# File 'lib/ml_dsa/batch_builder.rb', line 7 def initialize @ops = [] @mode = nil end |
Instance Method Details
#execute(config: MlDsa.config, yield_every: Internal::DEFAULT_YIELD_EVERY) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
39 40 41 42 43 44 45 46 |
# File 'lib/ml_dsa/batch_builder.rb', line 39 def execute(config: MlDsa.config, yield_every: Internal::DEFAULT_YIELD_EVERY) return [] if @ops.empty? if @mode == :sign MlDsa.sign_many(@ops, config: config, yield_every: yield_every) else MlDsa.verify_many(@ops, config: config, yield_every: yield_every) end end |
#sign(sk:, message:, context: nil, deterministic: false) ⇒ self
Add a sign operation to the batch.
18 19 20 21 22 23 |
# File 'lib/ml_dsa/batch_builder.rb', line 18 def sign(sk:, message:, context: nil, deterministic: false) check_mode!(:sign) @ops << SignRequest.new(sk: sk, message: , context: context, deterministic: deterministic) self end |
#verify(pk:, message:, signature:, context: nil) ⇒ self
Add a verify operation to the batch.
31 32 33 34 35 36 |
# File 'lib/ml_dsa/batch_builder.rb', line 31 def verify(pk:, message:, signature:, context: nil) check_mode!(:verify) @ops << VerifyRequest.new(pk: pk, message: , signature: signature, context: context) self end |