hyb
2026-01-30 7657e1b2fa251a2ea372710ad75cb395a3c0e374
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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
Ë
ž¬`iË$ãóp—ddlmZddlmZddlmZmZddlmZ    d„Z
d„Z Gd„de «Z Gd    „d
e «Zy ) é)Ú is_native_int)Únumber)Ú long_to_bytesÚ bytes_to_long)Úget_random_bytescóN—||kDr||}}d}|r|dzr||z}|dz}|dz}|rŒ|S)z!Multiply two polynomials in GF(2)ré©)Úf1Úf2Úzs   õpH:\项目\archive\测试组\脚本\Change_password\venv_build\Lib\site-packages\Crypto/Protocol/SecretSharing.pyÚ    _mult_gf2r(sJ€ð
ˆB‚wؐRˆBˆØ    €AÙ
Ø Š6Ø ‰GˆAØ
ˆq‰ˆØ
ˆq‰ˆò     ð
€HócóƗ||krd|fStj}d}|}||«}||«|k\r.d||«|z
z}||z}|t||«z}||«|k\rŒ.||fS)z˜
    Compute division of polynomials over GF(2).
    Given a and b, it finds two polynomials q and r such that:
 
    a = b*q + r with deg(r)<deg(b)
    rr    )rÚsizer)ÚaÚbÚdegÚqÚrÚdÚss       rÚ_div_gf2r7s~€ð    
ˆAŠØ!ˆtˆ ä
+‰+€CØ    €AØ    €AÙ ˆA‹€AÙ
ˆa‹&AŠ+Ø ‘#a“&˜1‘*Ñ ˆØ    ˆQ‰ˆØ    ŒYq˜!‹_шñ ˆa‹&A‹+ð ˆqˆ6€MrcóP—eZdZdZdddzzZd„Zd„Zd„Zd„Zd    „Z    d
„Z
d „Z d „Z y )Ú_ElementzElement of GF(2^128) fieldé‡éé€có|—t|«r||_yt|«dk(rt|«|_yt    d«‚)zïInitialize the element to a certain value.
 
        The value passed as parameter is internally encoded as
        a 128-bit integer, where each bit represents a polynomial
        coefficient. The LSB is the constant coefficient.
        éz8The encoded value must be an integer or a 16 byte stringN)rÚ_valueÚlenrÚ
ValueError)ÚselfÚ encoded_values  rÚ__init__z_Element.__init__Ts8€ô ˜Ô 'Ø'ˆDKÜ Ó  2Ò %Ü'¨ Ó6ˆDKäÐWÓXÐ Xrcó4—|j|jk(S©N©r")r%Úothers  rÚ__eq__z_Element.__eq__cs€Ø{‰{˜eŸl™lÑ*Ð*rcó—|jS)z7Return the field element, encoded as a 128-bit integer.r*©r%s rÚ__int__z_Element.__int__fs €à{‰{Ðrcó.—t|jd«S)z6Return the field element, encoded as a 16 byte string.r!)rr"r.s rÚencodez_Element.encodejs€ä˜TŸ[™[¨"Ó-Ð-rcó¦—|j}|j}||kDr||}}|j||fvr td«Sddz}|d}}|r€tt    |dz«dddzd¬«}|||z z||z
dz
|zz}|dz}tt    |dz    dz«dddzd¬«}|||jz z||z
dz
|zz}|dz}|rŒ€t|«S)Nrrrr    )Úbase)r"Úirr_polyrÚintÚbin)    r%Úfactorr r Úmask1Úvr Úmask2Úmask3s             rÚ__mul__z_Element.__mul__ns€à [‰[ˆØ ]‰]ˆð Š7ؘˆBà =‰=˜R ˜HÑ $ܘA“;Ð àS‘ˆØ1ˆ1ˆÙ䜘B ™F›  A B˜¨#Ñ-°AÔ6ˆEؘ!˜a™%‘ e¨e¡m°aÑ&7¸1Ñ%<Ñ=ˆAØ !‰GˆA䜘Q #™X¨™NÓ+¨A¨BÐ/°#Ñ5¸AÔ>ˆEؘ!˜dŸm™mÑ+Ñ,°%¸%±-À!Ñ2CÀqÑ1HÑIˆAØ 1‰HˆBòô˜‹{ÐrcóF—t|j|jz «Sr))rr")r%Úterms  rÚ__add__z_Element.__add__‡s€Ü˜Ÿ ™  d§k¡kÑ1Ó2Ð2rcóþ—|jdk(r td«‚|j|j}}d\}}|dkDr7t||«d}||t    ||«z }}||t    ||«z }}|dkDrŒ7t |«S)z0Return the inverse of this element in GF(2^128).rzInversion of zero)r    r)r"r$r4rrr)r%Úr0Úr1Ús0Ús1rs      rÚinversez_Element.inverseŠs€ð ;‰;˜!Ò ÜÐ0Ó1Ð 1à—‘˜dŸm™mˆBˆØ‰ˆˆBؐ1Šfܘ˜RÓ  Ñ#ˆAؘœi¨¨2Ó.Ñ.ˆBؘœi¨¨2Ó.Ñ.ˆBð1‹fô˜‹|Ðrcó`—t|j«}t|dz
«D]}||z}Œ    |S)Nr    )rr"Úrange)r%ÚexponentÚresultÚ_s    rÚ__pow__z_Element.__pow__›s6€Ü˜$Ÿ+™+Ó&ˆÜx !‘|Ó$ò    #ˆAؘd‘]‰Fð    #àˆ rN) Ú__name__Ú
__module__Ú __qualname__Ú__doc__r4r'r,r/r1r<r?rErKr
rrrrMs>„Ù$ð  c¡Ñ)€Hò Yò+òò.òò23òó"rrcó4—eZdZdZedd„«Zedd„«Zy)ÚShamirz›Shamir's secret sharing scheme.
 
    A secret is split into ``n`` shares, and it is sufficient to collect
    ``k`` of them to reconstruct the secret.
    c    óø—t|dz
«Dcgc]}ttd««‘Œ}}|jt|««d„}td|dz«Dcgc]}|||||«f‘Œc}Scc}wcc}w)a½Split a secret into ``n`` shares.
 
        The secret can be reconstructed later using just ``k`` shares
        out of the original ``n``.
        Each share must be kept confidential to the person it was
        assigned to.
 
        Each share is associated to an index (starting from 1).
 
        Args:
          k (integer):
            The number of shares needed to reconstruct the secret.
          n (integer):
            The number of shares to create (at least ``k``).
          secret (byte string):
            A byte string of 16 bytes (e.g. an AES 128 key).
          ssss (bool):
            If ``True``, the shares can be used with the ``ssss`` utility
            (without using the "diffusion layer").
            Default: ``False``.
 
        Return (tuples):
            ``n`` tuples, one per participant.
            A tuple contains two items:
 
            1. the unique index (an integer)
            2. the share (16 bytes)
        r    r!có¤—t|«}td«}|D]
}||z|z}Œ |r|t|«t|«zz }|j«S)Nr)rr#r1)ÚuserÚcoeffsÚssssÚidxÚshareÚcoeffs      rÚ
make_sharez Shamir.split.<locals>.make_shareÖs[€Ü˜4“.ˆCô˜Q“KˆEØò ,Ø˜e™  eÑ+‘ð ,ñØœ $›¬3¨v«;Ñ6Ñ6à—<‘<“>Ð !r)rGrÚrngÚappend)ÚkÚnÚsecretrVÚirUrZs       rÚsplitz Shamir.split©sv€ôN.3°1°q±5«\Ö:¨”(œ3˜r›7Õ#Ð:ˆÐ:؏ ‰ ”h˜vÓ&Ô'ò
    "ô";@ÀÀ1ÀqÁ5»/ÖJ°Q‘J˜q &¨$Ó/Ò0ÒJÐJùò/;ùò.Ks ‘A2ÁA7cóö‡—t|«}g}|D]Z}t|d«Št|d«}tˆfd„|D««r td«‚|r|‰|zz }|j    ‰|f«Œ\td«}t |«D]d}||\}}    td«}
td«} t |«D]} || d} | |k7sŒ|
| z}
| || zz} Œ||    |
z| j «zz }Œf|j«S)a’Recombine a secret, if enough shares are presented.
 
        Args:
          shares (tuples):
            The *k* tuples, each containing the index (an integer) and
            the share (a byte string, 16 bytes long) that were assigned to
            a participant.
 
            .. note::
 
                Pass exactly as many share as they are required,
                and no more.
 
          ssss (bool):
            If ``True``, the shares were produced by the ``ssss`` utility
            (without using the "diffusion layer").
            Default: ``False``.
 
        Return:
            The original secret, as a byte string (16 bytes long).
        rr    c3ó.•K—|] }|d‰k(–—Œy­w)rNr
)Ú.0ÚyrWs  €rú    <genexpr>z!Shamir.combine.<locals>.<genexpr>søèø€Ò2 11Q‘4˜3•;Ñ2ùsƒzDuplicate share)r#rÚanyr$r\rGrEr1)ÚsharesrVr]Ú    gf_sharesÚxÚvaluerIÚjÚx_jÚy_jÚ    numeratorÚ denominatorÚmÚx_mrWs              @rÚcombinezShamir.combineés"ø€ôL ‹Kˆàˆ    Øò    +ˆAܘ1˜Q™4“.ˆCܘQ˜q™T“NˆEÜÓ2¨    Ô2Ô2Ü Ð!2Ó3Ð3ÙØ˜ ™Ñ!Ø × Ñ ˜c 5˜\Õ *ð    +ô˜!“ˆÜq“ò     >ˆAØ  ‘|‰HˆCä  › ˆIÜ" 1›+ˆKä˜1“Xò -Ø ‘l 1‘oØ˜“6Ø Ñ$IØ 3¨¡9Ñ,‘Kð     -ð
c˜I‘o¨ ×(;Ñ(;Ó(=Ñ=Ñ =‰Fð     >ð}‰}‹ÐrN)F)rLrMrNrOÚ staticmethodrarsr
rrrQrQ¢s2„ñð ò=Kóð=Kð~ò?óñ?rrQN)ÚCrypto.Util.py3compatrÚ Crypto.UtilrÚCrypto.Util.numberrrÚ Crypto.Randomrr[rrÚobjectrrQr
rrú<module>rzs;ðõD0Ýß;Ý1ò  òô,RˆvôRôjGˆVõGr