• 0 Posts
  • 31 Comments
Joined 1 year ago
cake
Cake day: June 26th, 2023

help-circle
  • IANAL nor intelligent, but after skimming the text of the directive I felt like the definition of damage is very limited. In particular, if I understand correctly:

    our business to lose this giant contract

    would not be covered by this directive, this directive is only about a human being hurt in some way,

    thousands of consumers left with bricked devices

    would be covered in case of “your game installs a kernel-level anticheat and the anticheat breaks PCs”, but not in the case of “you uploaded an upgrade to a firmware of the washing machine you produced and it bricked the machines”; the directive is not about a product breaking, but about the product breaking your health, other property or data,

    my washing machine to eat my dog

    is basically the exact case this directive covers.



  • Hasn’t Google already made advances through its Alpha Geometry AI?? Admittedly, that’s a geometry setting which may be easier to code than other parts of Math and there isn’t yet a clear indication AI will ever be able to reach a certain level of creativity that the human mind has, but at the same time it might get there by sheer volume of attempts.

    Wanted to focus a bit on this. The thing with AlphaGeometry and AlphaProof is that they really treat doing math as a game, not unlike chess. For example, AlphaGeometry has a basic set of rules, it can apply them and it knows when it is done. And when it is done, you can be 100% sure that the solution is correct, because the rules of the game are known; the 28/42 score reported in the article is really four perfect scores and three zeros. Those systems do use LLMs, but they really are only there to suggest to the system what to try doing next. There is a very enlightening picture in the AlphaGeometry paper here: https://www.nature.com/articles/s41586-023-06747-5#Fig1

    You can automatically verify correctness of code the same way. For example Lean, the language AlphaProof uses internally, can be used for general programming. In general, we call similar programming techniques formal methods. But most people don’t do this, since this is more time-consuming than normal programming, and in many cases we don’t even know how to define the goal of our code (how to define correct rendering in a game?). So this is only really done when the correctness of the program is critical, like famously they verified the code of the automatic metro in Paris this way. And so most people don’t try to make programming AI work this way.


  • It seems OP wanted to pass the file name to -k, but this parameter takes the password itself and not a filename:

           -k password
               The password to derive the key from. This is for compatibility with previous versions of OpenSSL. Superseded by the -pass argument.
    

    So, as I understand, the password would be not the first line of /etc/ssl/private/etcBackup.key, but the string /etc/ssl/private/etcBackup.key itself. It seems that -kfile /etc/ssl/private/etcBackup.key or -pass file:/etc/ssl/private/etcBackup.key is what OP wanted to use.



  • pub trait Sum<A = Self>: Sized {
        fn sum<I: Iterator<Item = A>>(iter: I) -> Self;
    }
    

    So I’d presume the A = Self followed by I: Iterator<Item = A> for the iterator binds the implementation pretty clearly to the type of the iterator’s elements.

    Quite confusingly, the two =s have very different meaning here. The Item = A syntax just says that the iterator’s item type, which is set as the trait’s associated type, should be A. So, you could read this as “I should implement the Iterator trait, and the Item associated type of this implementation should be A”.

    However, A = Self does not actually mean any requirement of A. Instead, it means that Self is the default value of A: that is, you can do impl Sum<i64> for i32 and then you will have Self equal to i32 and A equal to i64, but you can also do impl Sum for i32 and it will essentially be a shorthand for impl Sum<i32> for i32, giving you both Self and A equal to i32.

    In the end, we have the relationship that the iterator item should be the same as A, but we do not have the relationship that Self should be the same as A. So, given this trait, the iterator item can actually be different to A.

    Note that the standard library does actually have implementations where these two differ. For instance, it has impl<'a> Sum<&'a i32> for i32, giving you a possibility to sum the iterator of &i32 into i32. This is useful when you think about this: you might want to sum such an iterator without .copied() for some extra ergonomics, but you can’t just return &i32, there is nowhere to store the referenced i32. So, you need to return the i32 itself.

    The definition is pretty clear here right? The generic here is Sum<Self::Item>, abbreviated to S … which AFAIU … means that the element type of the iterator — here Self::Item — is the type that has implemented Sum … and the type that will be returned.

    In Sum<Self::Item>, Self::Item is the A parameter, and Sum<Self::Item>, or S, is the type that implements the trait (which is called Self in the definition of the Sum trait, but is different to the Self in the sum method definition). As above, A and S can be different.

    It might be helpful to contrast this definition with a more usual one, where the trait does not have parameters:

    fn some_function<S>(…) ->where
            S: SomeTrait,
    {…}
    
    fn sum<S>(…) ->where
            S: Sum<Self::Item>,
    {…}
    

    Note that you might have an intuition from some other languages that in case of polymorphism, the chosen function either depends on the type of one special parameter (like in many OOP languages, where everything is decided by the class of the called object), or of the parameter list as a whole (like in C++, where the compiler won’t let you define int f() and float f() at the same time, but will be fine with int f(int) and float f(float)). As you can see, in Rust, the return type also matters. A simpler example of this is the Default trait.

    Regarding inference, some examples (Compiler Explorer link):

    vec![1i32].into_iter().sum();
    // or: <_ as Sum<_>>::sum(vec![1i32].into_iter());
    // error[E0283]: type annotations needed
    // note: cannot satisfy `_: Sum<i32>`
    

    Compiler knows that the iterator contains i32s, so it looks for something that implements Sum<i32>. But we don’t tell the compiler what to choose, and the compiler does not want to guess by itself.

    vec![1i32].into_iter().sum::<i32>();
    // or: <i32 as Sum<_>>::sum(vec![1i32].into_iter());
    

    As above the compiler knows that it wants to call something that implements Sum<i32>, but now it only has to check that i32 is such type. It is, so the code compiles.

    vec![1i32].iter().sum::<i32>();
    // or: <i32 as Sum<_>>::sum(vec![1i32].iter());
    

    Now we actually have a iterator of references, as we used .iter() instead of .into_iter(). But the code still compiles, since i32 also implements Sum<&i32>.

    vec![1i64].into_iter().sum::<i32>();
    // or: <i32 as Sum<_>>::sum(vec![1i64].into_iter());
    // error[E0277]: a value of type `i32` cannot be made by summing an iterator over elements of type `i64`
    // help: the trait `Sum<i64>` is not implemented for `i32`
    

    Now the compiler can calculate itself that it want to call something that implements Sum<i64>. However, i32 does not actually implement it, hence the error. If it did, the code would compile correctly.

    vec![].into_iter().sum::<i32>();
    // or: <i32 as Sum<_>>::sum(vec![].into_iter());
    // error[E0283]: type annotations needed
    // (in the second case) note: multiple `impl`s satisfying `i32: Sum<_>` found in the `core` crate: impl Sum for i32; impl<'a> Sum<&'a i32> for i32;
    

    Now the situation is reversed. The compiler knows the return type, so it knows that i32 should implement some Sum<_>. But it doesn’t know the iterator element type, and so it doesn’t know if it should choose the owned value, or the reference version. Note that the wording is different, the compiler wants to guess, but it can’t, as there are multiple possible choices. But if there is only one choice, the compiler does guess it:

    struct X {}
    impl Sum for X {
        fn sum<I: Iterator<Item = X>>(_: I) -> Self { Self{} }
    }
    vec![].into_iter().sum::<X>();
    // or: <X as Sum<_>>::sum(vec![].into_iter());
    

    builds correctly. I am not sure about the reason for the difference (I feel like it’s related to forward compatibility and the fact that outside the standard library I can do impl Sum<i32> for MyType but not impl Sum<MyType> for i32, but I don’t really know).

    Hope that helps :3

    EDIT:

    I’d also caught mentions of the whole zero thing being behind the design. Which is funny because once you get down to the implementation for the numeric types, zero seems (I’m not on top of macro syntax) to be just a parameter of the macro, which then gets undefined in the call of the macro, so I have to presume it defaults to 0 somehow??. In short, the zero has to be provided in the implementation of sum for a specific type. Which I suppose is flexible. Though in this case I can’t discern what the zero is for the integer types (it’s explicitly 0.0 for floats).

    Ah, I read this, thought about this, and forgot about this almost immediately. I know almost nothing about macros, but if I understand correctly, the zero is in line 92, here:

        ($($a:ty)*) => (
            integer_sum_product!(@impls 0, 1,
                    #[stable(feature = "iter_arith_traits", since = "1.12.0")],
                    $($a)*);
            integer_sum_product!(@impls Wrapping(0), Wrapping(1),
                    #[stable(feature = "wrapping_iter_arith", since = "1.14.0")],
                    $(Wrapping<$a>)*);
        );
    

    The intention seems to be to take a list of types (i8 i16 i32 i64 i128 isize u8 u16 u32 u64 u128 usize), and then for each type to generate both the regular and Wrapping version, each time calling into the path you have seen before. For floats there is no Wrapping version, so this time 0.0 is really the only kind of zero that can appear.




  • metiulekm@sh.itjust.workstoProgramming@programming.dev...
    link
    fedilink
    English
    arrow-up
    3
    arrow-down
    1
    ·
    7 months ago

    I really need to try out Mercury one day. When we did a project in Prolog at uni, it felt cool, but also incredibly dynamic in a bad way. There were a few times when we misspelled some clause, which normally would be an error, but in our case it just meant falsehood. We then spent waaay to much time searching for these. I can’t help but think that Mercury would be as fun as Prolog, but less annoying.

    I actually use from time to time the Bower email client, which is written in Mercury.



  • I’m betting there’s probably something that generates the key from a vastly smaller player input, i.e what gameobjects you interacted with, in what order, or what did you press/place somwhere. But that also means that the entropy is probably in the bruteforcable range, and once you find the function that decrypts the secrets, it should be pretty easy to find the function that generates the key, and the inputs it takes.

    When handling passwords, it is standard practice to use an intentionally costly (in CPU, memory, or both) algorithm to derive the encryption key from the password. Maybe the dev can reuse this? The resulting delay could easily be masked with some animation.








  • Random guess: your GPU is managed by logind and bound to your session. When your session ends, logind takes away the permissions. This kind of makes sense, if somebody else were to physically login on your PC, they should get (probably exclusive) access to the GPU.

    Not sure if this is even a good idea since I have never researched this, but maybe you can just write some udev rules to ensure that your user always has permissions to access the device?



  • In Poland:

    • driver’s permits are not a thing. In general, it’s illegal to drive without a professional instructor (with parents, for example) before getting a driving license, though a lot of people, especially in the countryside, will still do so,
    • you can only drive after turning 18. You can start the course a few months earlier, but you can only take the final exam after you turn 18 (there exists a category that allows you to drive after turning 16, but it’s limited and IME extremely unpopular),
    • you need to go to a paid course, which includes theory classes and at least 30 hours of driving with the instructor,
    • most people drive in a car owned by the instructor or the driving school, as the car must have another pair of brakes for the instructor,
    • you need to pass a theoretical and a practical exam in one of the centers (Wojewódzki ośrodek ruchu drogowego),
    • the theoretical exam is just closed questions. You need to get 68 out of 74 points, but (AFAIK, this has changed over time) all the questions are known, so people will just cram them,
    • the practical exam is first some maneuvers on the center grounds, and then a ride around the city. The exam is rather objective and is failed if you do any big mistake or fail any exercise twice,
    • the exams are not easy. The data I found is for each WORD, but in general I feel like the pass rate is around 50% for the practical exam and 70% for theory. It’s not incommon for somebody to only pass their practical exam on like 5th attempt,
    • there were supposed to be some restrictions for new drivers, but they had been discussed for a long time, even back when I passed my license before the pandemic, and I have no idea if they ever actually came into force,
    • some people think that the system is super flawed. Here’s some discussion by the Supreme Audit Office in Polish: https://www.nik.gov.pl/aktualnosci/system-szkolenia-kandydatow-na-kierowcow.html,
    • costwise, it’s apparently like 4000 zł for the course right now. Exams are paid per attempt, 50 zł for the theory and 200 zł for practice. 1 euro is 4.33 zł as of writing, but you need to take into account the difference in purchasing power and it’s probably not much cheaper than Germany even if you pass both exams the first time.