File size: 2,296 Bytes
d6f21bb
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
"""Topological resource estimates for SHA-520-r experiments."""

from __future__ import annotations

from dataclasses import dataclass, asdict
import math
from typing import Dict

from qlambda.arrays import FALSIFICATION_CRITERIA


@dataclass(frozen=True)
class TopologicalEstimate:
    rounds: int
    target_bits: int
    logical_qubits: int
    physical_anyons: int
    grover_iterations: int
    qir_gates_per_round: int
    braids_per_round: int
    total_braids: int
    braid_time_ns: float
    total_time_sec: float
    oracle_dominates: bool
    falsification_flags: Dict[str, str]

    def to_dict(self) -> Dict[str, object]:
        return asdict(self)


def estimate_sha520_r_topological(

    rounds: int,

    target_bits: int,

    braid_time_ns: float = 10.0,

    sk_factor: int = 300,

) -> TopologicalEstimate:
    if rounds <= 0:
        raise ValueError("rounds must be positive")
    if target_bits <= 0:
        raise ValueError("target_bits must be positive")

    logical_qubits = 1024 + 520 + max(600 * rounds, 100)
    physical_anyons = logical_qubits * 4
    grover_iterations = int((math.pi / 4.0) * math.sqrt(2**target_bits))
    qir_gates_per_round = 1000
    braids_per_round = 35000
    total_braids = grover_iterations * rounds * braids_per_round
    total_time_sec = total_braids * braid_time_ns * 1e-9

    flags: Dict[str, str] = {}
    if sk_factor > 10000:
        flags["braid_overhead_excessive"] = FALSIFICATION_CRITERIA["braid_overhead_excessive"]
    if qir_gates_per_round > 900:
        flags["oracle_dominates"] = FALSIFICATION_CRITERIA["oracle_dominates"]
    if braid_time_ns > 1000.0:
        flags["adiabatic_too_slow"] = FALSIFICATION_CRITERIA["adiabatic_too_slow"]

    return TopologicalEstimate(
        rounds=rounds,
        target_bits=target_bits,
        logical_qubits=logical_qubits,
        physical_anyons=physical_anyons,
        grover_iterations=grover_iterations,
        qir_gates_per_round=qir_gates_per_round,
        braids_per_round=braids_per_round,
        total_braids=total_braids,
        braid_time_ns=braid_time_ns,
        total_time_sec=total_time_sec,
        oracle_dominates="oracle_dominates" in flags,
        falsification_flags=flags,
    )