zkmopro / zkmopro/gpu-acceleration

`jacobian_scalar_mul` issues in terms of performance and data type

Open
#40 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Rust
Stars
29
Forks
12
PR merge metrics
No merged PRs in 30d

Description

Problem

There might be several issues in jacobian_scalar_mul().

Details

current scalar is a uint
Jacobian jacobian_scalar_mul(
    Jacobian point,
    uint scalar
) {
///...
}

The scalar used here is constrained by the default GPU word size, which is 32-bit. Note that this function is suitable for MSM use cases because the scalar fragments involved in MSM are relatively small. However, for larger scalars, this may produce incorrect results. Thus, for now we expect ppl to NOT send a large scalar (BigInt as input) in scalar_mul.

probably we should add a BigInt scalar as the input if there's necessary.

conditional lock in jacobian_scalar_mul
    // Handle special cases first
    if (scalar == 0 || is_bigint_zero(point.z)) {
        return get_bn254_zero_mont();
    }
    if (scalar == 1) {
        return point;
    }

Potential acceleration can be achieved by moving the condition checks directly into the MSM logic.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Locate jacobian_scalar_mul and the MSM logic, then read how scalar types and the special-case checks are handled. Compare the uint limitation and conditional checks against the stated larger-scalar and performance concerns; done means the supported scalar behavior and any MSM optimization are implemented and verified.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp, rust
Domain
cryptography, hpc, performance
Issue type
Refactor
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.